[limb-svn] r6051 - in 3.x/trunk/limb/dbal: src tests/cases/non-driver
svn at limb-project.com
svn at limb-project.com
Tue Jul 3 14:32:53 MSD 2007
Author: serega
Date: 2007-07-03 14:32:53 +0400 (Tue, 03 Jul 2007)
New Revision: 6051
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6051
Modified:
3.x/trunk/limb/dbal/src/lmbSimpleDb.class.php
3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php
Log:
-- lmbSimpleDb :: select() accepts $order not as a string but as an array like array('field1' => 'order_type', 'field2' => 'order_type');
Modified: 3.x/trunk/limb/dbal/src/lmbSimpleDb.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/lmbSimpleDb.class.php 2007-07-03 08:56:00 UTC (rev 6050)
+++ 3.x/trunk/limb/dbal/src/lmbSimpleDb.class.php 2007-07-03 10:32:53 UTC (rev 6051)
@@ -38,20 +38,22 @@
return $this->conn->getType();
}
- function select($table, $criteria = null, $order = '')
+ function select($table, $criteria = null, $order = array())
{
$query = new lmbSelectQuery($table);
if($criteria)
$query->addCriteria(lmbSQLCriteria :: objectify($criteria));
- if($order)
- $query->addOrder($order);
+ $rs = $query->getRecordSet($this->conn);
- return $query->getRecordSet($this->conn);
+ if(is_array($order) && sizeof($order))
+ $rs->sort($order);
+
+ return $rs;
}
- function selectAsArray($table, $criteria = null, $order = '', $key_field = '')
+ function selectAsArray($table, $criteria = null, $order = array(), $key_field = '')
{
$rs = $this->select($table, $criteria, $order);
return $rs->getArray($key_field);
Modified: 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php 2007-07-03 08:56:00 UTC (rev 6050)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php 2007-07-03 10:32:53 UTC (rev 6051)
@@ -139,6 +139,24 @@
$this->assertEqual($record->get('description'), 'description2');
}
+ function testSelectWithOrder()
+ {
+ $data = array(
+ 0 => array('title' => 'aaa', 'description' => 'description'),
+ 1 => array('title' => 'zzz', 'description' => 'description2'),
+ 2 => array('title' => 'kkk', 'description' => 'description3')
+ );
+
+ $this->db->insert('test_db_table', $data[0]);
+ $this->db->insert('test_db_table', $data[1]);
+ $this->db->insert('test_db_table', $data[2]);
+
+ $result = $this->db->select('test_db_table', null, array('title' => 'DESC'))->getArray();
+ $this->assertEqual($result[0]->get('title'), 'zzz');
+ $this->assertEqual($result[1]->get('title'), 'kkk');
+ $this->assertEqual($result[2]->get('title'), 'aaa');
+ }
+
function testDeleteAll()
{
$data = array(
More information about the limb-svn
mailing list