php pdo这个查询没有运行,但它在phpmyadmin上运行顺畅

时间:2017-07-12 04:03:48

标签: php pdo

此查询可以在phpmyadmin上顺利运行。但是在我的项目中,它不是在查询。

$sql = 'SELECT p.est_id,p.sec_plan_number,p.plot_plan_number,
                    (select policyno from tbl_plot_statusd where est_id=p.est_id 
                    and sec_plan_number=p.sec_plan_number and plot_plan_number=p.plot_plan_number 
                    and op_id=ps.op_id) as policyno, (select nic from tbl_plot_statusd 
                    where est_id=p.est_id and sec_plan_number=p.sec_plan_number 
                    and plot_plan_number=p.plot_plan_number and op_id=ps.op_id) as nic 
                    FROM `tbl_plot` p left join tbl_plot_status ps on p.est_id=ps.est_id 
                    and p.sec_plan_number = ps.sec_plan_number and p.plot_plan_number=ps.plot_plan_number 
                    where ps.status_type_code=2 and ps.is_last_status=1 and p.isactive=1 
                    order by ps.est_id,ps.sec_plan_number,abs(ps.plot_plan_number)';
 foreach ($db->query($sql) as $d) 

1 个答案:

答案 0 :(得分:0)

尝试

$query = $db->query($sql);
foreach ($query->fetchAll() as $d)
{

}