2011-07-07 7 views

Odpowiedz

24

Co o tym:

 $db = Zend_Db_Table::getDefaultAdapter(); 

     $select = $db->select(); 

     $select->from('table_name') 
       ->order(new Zend_Db_Expr("FIELD(field_name, 'Small','Medium','Large')")); 


     var_dump($select->assemble()); 

Wyniki w:

string 'SELECT `table_name`.* FROM `table_name` ORDER BY FIELD(field_name, 'Small','Medium','Large')' (length=92) 
+0

beat mnie do niego! ;-) –

+0

Dziekuje! dzięki :) – srgb

1
$select->order(new Zend_Db_Expr('FIELD(field_name, 'Small','Medium','Large')')); 
1

myślę, że należy zrobić:

$db = Zend_Db::factory(...options...); 
$select = $db->select() 
->from(table_name) 
->order(new Zend_Db_Expr("FIELD(field_name, 'Small','Medium','Large')")));