|
发表于 2016-2-19 11:48:46
|
显示全部楼层
我写的一个递归:希望有更好的写法
function child($product_id,$j) /////递归,得到出各级物料的的用量
{
$sql=" select child_material_id,qty as single_qty from bom as a
left join material as b on a.child_material_id=b.material_id where product_id=".$product_id;
$query =$this->db->query($sql);
if($query->num_rows() > 0){
foreach ($query->result_array() as $row)
{
$m='||'.$row['child_material_id'].'|'.$row['single_qty'];
$j.=$m.$this->mmaterial->child($row['child_material_id'],$j);
}
}
return $j;
} |
|