Zend_Db order by field Value

后端 未结 2 633
北海茫月
北海茫月 2021-01-23 22:08

I\'m outputting the contents of a select menu from a model using this:

$select = $this->select();
$select->order(\'name\');
return $this->fetchAll($sele         


        
相关标签:
2条回答
  • 2021-01-23 22:56

    I believe this is what you are looking for:

    $name = 'John';
    $order = new Zend_Db_Expr($this->getAdapter()->quoteInto("name = ?", $name) ." DESC, `name`");
    $select = $this->select();
    $select->order($order);
    return $this->fetchAll($select);
    
    0 讨论(0)
  • 2021-01-23 23:00

    depending on your SQL DB, this is not supported. (i dont know a database which can sort directly by a string.)

    what would you want to accomplish ? have fields with someValue at the first positions

    0 讨论(0)
提交回复
热议问题