本文主要是介绍phalcon原生SQL查询,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原生SQL联合查询数据,PHQL不支持union。
$sql = "(select s.* from oa_store s where s.other_name like '%广州%' order by s.sort asc) union (select s.* from oa_store s where s.other_name not like '%深圳%' order by s.sort asc) limit 0,10";
$dbs = \Phalcon\DI::getDefault()->get('dbs');
$stmt = $dbs->prepare($sql);
$stmt->execute([]);
$oneResult = $stmt->fetchAll(\PDO::FETCH_ASSOC);
var_dump($oneResult);exit;
原生SQL跨库联表查询
$sql = "select c.name,g.phone from ecshop.ecs_recom c left join arshop.ar_goods g on c.id=g.id where c.id=1";
$ecshopdb = \Phalcon\DI::getDefault()->get('ecshopdb');
$stmt = $ecshopdb->prepare($sql);
$stmt->execute([]);
$oneResult = $stmt->fetchAll(\PDO::FETCH_ASSOC);
var_dump($oneResult);exit;
这篇关于phalcon原生SQL查询的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!