OK.  This works.

$select->order(array(new Expression("(page * 1)")));


On Mon, Jul 21, 2014 at 2:48 PM, John Wynstra <[email protected]> wrote:

> The following SQL statement casts the *page *column (type = string) as a
> number and sorts it as such.  It runs fine against a mysql database console.
>
> select title, *page* from articles where issue_id = '18641' order by
> (page *1);
>
> I can not get the *Order by (page *1) *to function in a Zend_Db_Select.
>  Is there way to do this?  The documentation does not indicate that Order
> by can take an expression.
>
>
> $sql = new Sql($adapter);
>           $select = $sql->select();
>           $select->from(array('a'=>'articles'),
>           array('title', 'page'));
>         $select->where(array('issue_id'=>$value));
>        * $select->order(array('(page*1)'));*
>           $statement = $sql->prepareStatementForSqlObject($select);
>           $results = $statement->execute();
>
> --
> ------------------------------------------------
> John Wynstra
> Library Information Systems Specialist
> Rod Library
> University of Northern Iowa
> Cedar Falls, IA  50613
> [email protected]
> (319)273-6399
> ------------------------------------------------
>



-- 
------------------------------------------------
John Wynstra
Library Information Systems Specialist
Rod Library
University of Northern Iowa
Cedar Falls, IA  50613
[email protected]
(319)273-6399
------------------------------------------------

Reply via email to