我们在公司使用Zend Framework,因此我们使用的是Zend_Db_Select。
现在我们正在用它构建一个查询,然后将(预取)传递给一个函数。 查询构建如下:
$select = $this->_selectAll()
->setIntegrityCheck(false)
->joinLeft('shop', $conShop, $colShop)
->joinLeft('ptool', $conPtool, $colPtool)
->where('ptool.product_id > 0')
->where('ptool.product_is_from_shop = 0')
;
$ conShop和$ colShop类似于:
$colShop = array('shop_id','shop_channel');
$conShop = "shop.shop_id = ptool.shop_id";
在一个新方法中,我希望获得所有已连接的表及其将被选中的列。所以$ select被传递给方法,现在我想得到这样的东西:
Array
(
['shop'] => Array
(
[0] => 'shop_id',
[1] => 'shop_channel',
...
),
['ptool'] => Array
(
[0] => 'shop_id',
[1] => 'ptool_id',
...
),
...
)
如果我能得到这个预取,那就太好了。
背景是我想按shop_id排序,例如,这个表名用于两个连接表。如果我执行“ORDER BY shop_id”之类的操作,我会收到列不明确的错误。这就是为什么我需要知道哪些列属于哪个表,以便我可以做“ORDER BY shop.shop_id”这样的事情
希望你能帮助我。谢谢! :)