Search code examples
phpzend-frameworkzend-db-tablezend-db-select

Extracting query parts through Zend_Db_Rowset


I am building a class that only receive a Zend_Db_Rowset throught its params and from that I can extract the related Zend_Db_Table using the $rowset->getTable() method.

I was wondering if there is a way to get the order statement back from the table since I can set it (as a private property) through a dump.

object(Application_Model_DbTable_View_Formation)#107 (18) {
...
    ["_rows":protected] => array(4) {
      [0] => array(3) {
        [0] => string(7) "0.04095"
        [1] => string(20) "DESCRIBE `formation`"
        [2] => NULL
      }
      [1] => array(3) {
        [0] => string(7) "0.00047"
        [1] => string(67) "SELECT `formation`.* FROM `formation` ORDER BY `date` desc LIMIT 30"
        [2] => NULL
      }
      [2] => array(3) {
        [0] => string(7) "0.02031"
        [1] => string(22) "DESCRIBE `v_formation`"
        [2] => NULL
      }
      [3] => array(3) {
        [0] => string(7) "0.02285"
        [1] => string(135) "SELECT `v_formation`.* FROM `v_formation` WHERE (date >= '2011-01-01 12:00:00') AND (date <= '2011-12-31 11:59:59') ORDER BY `date` ASC"
        [2] => NULL
      }
    }
   ...
}

Solution

  • What you see is Zend_Db_Profiler data. This has no relation to the actual rowset. I think you can't get the select that created that rowset.

    Speaking strictly about the order for the table. You can't receive it per-se. You can only create a select with order using public $table->select()->order('id DESC'); method.