Thanks Bill
I am using PEAR structures - so I throw the results straight into that,
and hence keeping the column order is important to save on overhead of
code used in Structures, I am now ordering in this now.
Cheers
Ian
Bill Karwin wrote:
Currently Zend_Db_Select sorts columns by the correlation name as it
builds the query. I can log a feature request to preserve the column
order, and we'll try fixing it at some later time.
But I need to give the disclaimer that I would not choose to prioritize
this change very high, relative to other improvements to Zend_Db we need
to do. Since the result set of a query is usually returned as an
associative array anyway, the difference of column-order is pretty
trivial.
If you have specific needs that are not satisfied by Zend_Db_Select, the
workaround I can offer right away is that you can put SQL into a string
manually, and execute it with the query() method.
Regards,
Bill Karwin
-----Original Message-----
From: Ian Warner [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 25, 2007 11:17 AM
To: Zend Framework
Subject: [fw-general] DB Select
Hi
I want to select the following in the following column order:
$select = $db->select()
->from(array('a' => $config->$table), array('a.code',
'b.company', 'a.sale_date'))
->joinLeft(array('b' =>
$config->db_tbl_finances_debtors),
'a.debtor_id = b.debtor_id', array())
->order('a.code DESC');
When th SQL is generated I get this:
[_query:protected] => SELECT
`a`.`code`,
`a`.`sale_date`,
`b`.`company`
FROM `finances_invoices` AS `a`
LEFT JOIN `finances_debtors` AS `b` ON a.debtor_id = b.debtor_id
ORDER BY
`a`.`code` DESC
It has reordered the Columns!!
How do I stop this doing this behaviour.
Cheers
Ian