Fixing the problem with order and \Zend\Db\Sql\Expression #3017

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+6 −0
Diff settings

Always

Just for now

@@ -340,6 +340,8 @@ public function order($order)
} else {
$order = (array) $order;
}
+ } elseif ($order instanceof Expression){
+ $order = array($order);
}
foreach ($order as $k => $v) {
if (is_string($k)) {
@@ -260,6 +260,10 @@ public function testOrder()
$select = new Select;
$select->order(array('name ASC', 'age DESC'));
$this->assertEquals(array('name ASC', 'age DESC'), $select->getRawState('order'));
+
+ $select = new Select;
+ $select->order(new \Zend\db\sql\Expression('id DESC'));
+ $this->assertEquals('id DESC', current($select->getRawState('order'))->getExpression());
}
/**