Quantcast

natural order sorting in select object

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

natural order sorting in select object

tonystamp
Heya folks.

I normally make mysql enforce natural order sorting by simply adding +0 prior to the asc clause eg
order by house_number asc +0

How can i do this with the zend_db_select object?
$select->order('house_number +0 asc')
does not work.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: natural order sorting in select object

BillKarwin

tony stamp wrote
How can i do this with the zend_db_select object?
$select->order('house_number +0 asc')
does not work.
The Select object tries to quote identifiers, in case your column name contains a SQL keyword, whitespace, or special characters.  

Try this:

  $select->order(new Zend_Db_Expr('house_number +0 ASC'));

Regards,
Bill Karwin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: natural order sorting in select object

Simon Mundy
In reply to this post by tonystamp
Hi Tony

$select->order(new Zend_Db_Expr('house_number +0 asc'));

will do the job nicely for you!

Cheers

> Heya folks.
>
> I normally make mysql enforce natural order sorting by simply adding  
> +0
> prior to the asc clause eg
> order by house_number asc +0
>
> How can i do this with the zend_db_select object?
> $select->order('house_number +0 asc')
> does not work.
> --
> View this message in context: http://www.nabble.com/natural-order-sorting-in-select-object-tp19412845p19412845.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>

--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "

202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654  
4124
http://www.peptolab.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: natural order sorting in select object

oreales
sorry for the offtopic, but it could be helpful:

that query will have a bad effect in the MySQL side, because "indexes"  
can be used, so it is neccesary make the arhitmetic operation in every  
records before order...........

El 23 Sep 2008, a las 04:42, Simon Mundy escribió:

> Hi Tony
>
> $select->order(new Zend_Db_Expr('house_number +0 asc'));
>
> will do the job nicely for you!
>
> Cheers
>
>> Heya folks.
>>
>> I normally make mysql enforce natural order sorting by simply  
>> adding +0
>> prior to the asc clause eg
>> order by house_number asc +0
>>
>> How can i do this with the zend_db_select object?
>> $select->order('house_number +0 asc')
>> does not work.
>> --
>> View this message in context: http://www.nabble.com/natural-order-sorting-in-select-object-tp19412845p19412845.html
>> Sent from the Zend DB mailing list archive at Nabble.com.
>>
>
> --
>
> Simon Mundy | Director | PEPTOLAB
>
> """ " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
>
> 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
> Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654  
> 4124
> http://www.peptolab.com
>

Loading...