天天看點

模闆上 php dede,dedecms模闆中{dede:php}标簽結合SQL查詢

通過{dede:php}标簽,結合SQL查詢,實作各種業務需求的查詢輸出,更加靈活應用

//查詢單條内容{dede:php}

$row = $dsql->GetOne('select id,typename from dede_arctype where id=10');

print_r($row);//列印出相關結果數組

{/dede:php}

//查詢多條内容$db->SetQuery($dsql);  //$dsql 為sql語句

$db->Execute();

while($arr = $db->GetArray())

{

//循環多條内容

}

//嵌套多級循環查詢$db->Execute('one',$dsql); //$dsql 為sql語句

while($arr = $db->GetArray('one'))

{

$db->Execute('two',$dsql2); //$dsql2 為sql2語句

while($arr2 = $db->GetArray('two'))

{

}

}

//one 和 two 就是兩個遊标标記,但要注意,在getArray()裡也要添加這個參數!

本文位址:http://www.8080e.cn/post/59.html    轉載請注明來源