zfdatagrid / grid

A DataGrid library for Zend Framework
BSD 3-Clause "New" or "Revised" License
10 stars 16 forks source link

Using zend_db_select problem #836

Closed imonteiro closed 11 years ago

imonteiro commented 11 years ago

Original author: chonn...@gmail.com (March 27, 2009 15:19:37)

So it is my query: $s = $this->db->select(); $s->from(array('p'=>'tb_mats_prodin'),array('id','PLabel','count','length','width','thickness'))

->joinLeft(array('u'=>'tb_measures'),'p.unit_id=u.id',array('measure')) ->joinLeft(array('m'=>'tb_materials'),'p.mat_id=m.id',array('material')) ->joinLeft(array('pr'=>'tb_products'),'p.prod_id=pr.id',array('product')) ->joinLeft(array('s'=>'tb_selections'),'p.sel_id=s.id',array('selection')) ->joinLeft(array('q'=>'tb_qualities'),'p.qual_id=q.id',array('quality')) ->joinLeft(array('pc'=>'tb_processing'),'p.proc_id=pc.id',array('processing')) ->joinLeft(array('apc'=>'tb_add_processing'),'p.add_proc_id=apc.id',array('add_processing')) ->joinLeft(array('c'=>'tb_mats_categories'),'p.cat_id=c.id',array('category')) ->joinLeft(array('po'=>'tb_mats_prodout'),'p.id=po.pid',array()) ->where('po.pid is null');

When I print it and query it via phpmyadmin everything is fine

SELECT p.id, p.PLabel, p.count, p.length, p.width, p.thickness, u.measure, m.material, pr.product, s.selection, q.quality, pc.processing, apc.add_processing, c.category FROM tb_mats_prodin AS p LEFT JOIN tb_measures AS u ON p.unit_id=u.id LEFT JOIN tb_materials AS m ON p.mat_id=m.id LEFT JOIN tb_products AS pr ON p.prod_id=pr.id LEFT JOIN tb_selections AS s ON p.sel_id=s.id LEFT JOIN tb_qualities AS q ON p.qual_id=q.id LEFT JOIN tb_processing AS pc ON p.proc_id=pc.id LEFT JOIN tb_add_processing AS apc ON p.add_proc_id=apc.id LEFT JOIN tb_mats_categories AS c ON p.cat_id=c.id LEFT JOIN tb_mats_prodout AS po ON p.id=po.pid WHERE (po.pid is null)

Problem is when I use it with grid $grid->queryFromZendDbSelect($s);

exception info

exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'u.idleft' in 'on clause'' in C:\wamp\frameworks\Zend\Db\Statement\Pdo.php:238 Stack trace: #0 C:\wamp\frameworks\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 C:\wamp\frameworks\Zend\Db\Adapter\Abstract.php(433): Zend_Db_Statement->execute(Array) #2 C:\wamp\frameworks\Zend\Db\Adapter\Pdo\Abstract.php(230): Zend_Db_Adapter_Abstract->query('SELECT p.id, p....', Array) #3 C:\wamp\frameworks\Zend\Db\Adapter\Abstract.php(644): Zend_Db_Adapter_Pdo_Abstract->query('SELECT p.id, p....', Array) #4 C:\wamp\projects\erp\library\Bvb\Grid\DataGrid.php(2754): Zend_Db_Adapter_Abstract->fetchAll('SELECT p.id, p....') #5 C:\wamp\projects\erp\library\Bvb\Grid\Deploy\Table.php(1833): Bvb_Grid_DataGrid->deploy() #6 C:\wamp\projects\erp\application\Mats\controllers\AddController.php(220): Bvb_Grid_Deploy_Table->deploy() #7 C:\wamp\frameworks\Zend\Controller\Action.php(503): Mats_AddController->prodoutAction() #8 C:\wamp\frameworks\Zend\Controller\Dispatcher\Standard.php(285): Zend_Controller_Action->dispatch('prodoutAction') #9 C:\wamp\frameworks\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #10 C:\wamp\projects\erp\application\bootstrap.php(30): Zend_Controller_Front->dispatch() #11 C:\wamp\projects\erp\public\index.php(8): require('C:\wamp\project...') #12 {main}

Original issue: http://code.google.com/p/zfdatagrid/issues/detail?id=30

imonteiro commented 11 years ago

From pao.fre...@gmail.com on July 14, 2009 20:41:40 This grid now uses the Zend_Db_Select to perform queries.

Please wait for the next release or try the latest revision from SVN.

$gri->query(Zend_Db_Select instance);

imonteiro commented 11 years ago

From pao.fre...@gmail.com on July 14, 2009 20:41:41 This grid now uses the Zend_Db_Select to perform queries.

Please wait for the next release or try the latest revision from SVN.

$gri->query(Zend_Db_Select instance);