We are using the Zend Framework in our company and thus we're using Zend_Db_Select.
Now we are building a query with it which is then (pre fetch) passed to a function. The query is built as follows:
$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')
;
Where $conShop and $colShop are something like:
$colShop = array('shop_id','shop_channel');
$conShop = "shop.shop_id = ptool.shop_id";
In a new method I want to get all joined tables and their columns that are going to be selected. So the $select gets passed to the method and now I would like to get something like this:
Array
(
['shop'] => Array
(
[0] => 'shop_id',
[1] => 'shop_channel',
...
),
['ptool'] => Array
(
[0] => 'shop_id',
[1] => 'ptool_id',
...
),
...
)
It would be nice if I can get this pre fetch.
The background is that I want to sort by shop_id for example and this table name is used in two joined tables. If I do something like "ORDER BY shop_id" I'd get the error that the column is ambiguous. That's why I need to know which columns belong to which table so that I can do something like "ORDER BY shop.shop_id"
Hope you can help me. Thanks! :)