您好,登錄后才能下訂單哦!
無限級服務端數據組織方案的實現,提供解決方案,其中數據庫查詢可替換為List的方式查找等其它方式。
function queryAllSubCustomers($cstId) {
$sqlA="SELECT ID, Name, ParentID FROM T_CustomerInfo WHERE ID = $cstId ";
$custList=Sql_Query($sqlA);
$AllCustInfs=array();
$result=array();
while(count($custList) > 0) {
// 組建當前客戶列表,獲取所有id
$countNum = count($custList);
$subCustIds=" (";
//print_r($custList);
for ($i=0; $i<$countNum; $i++) {
$custInf = $custList[$i];
$node=array();
$node['id']=$custInf['ID'];
$node['text']=$custInf['Name'];
array_push($AllCustInfs,$node);
$subCustIds = $subCustIds.$custInf['ID']."," ;
}
$subCustIds = substr($subCustIds,0,-1).") ";
// 查詢下級客戶
$sql="SELECT ID, Name, ParentID FROM T_CustomerInfo WHERE ParentID <> 0 AND ParentID IN $subCustIds ";
unset($subCustIds);
unset($custList);
$custList=Sql_Query($sql);
//print_r($custList);
}
return $AllCustInfs;
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。