fixing check in magic methods for a value otherwise it will return false adding test to dbosource

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4746 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-04-03 05:43:31 +00:00
parent a1e535a05d
commit ed342c307d
2 changed files with 8 additions and 3 deletions

View file

@ -212,14 +212,14 @@ class DboSource extends DataSource {
$order = $params[2 + $off]; $order = $params[2 + $off];
} }
if(!isset($params[0])) { if(!array_key_exists(0, $params)) {
return false; return false;
} }
$c = 0; $c = 0;
$query = array(); $query = array();
foreach ($field as $f) { foreach ($field as $f) {
if (!is_array($params[$c])) { if (!is_array($params[$c]) && !empty($params[$c])) {
$query[$args[2]->name . '.' . $f] = '= ' . $params[$c]; $query[$args[2]->name . '.' . $f] = '= ' . $params[$c];
} else { } else {
$query[$args[2]->name . '.' . $f] = $params[$c]; $query[$args[2]->name . '.' . $f] = $params[$c];

View file

@ -1381,6 +1381,11 @@ class DboSourceTest extends UnitTestCase {
$result = $this->db->query('findByFieldName', array('= a'), $this->model); $result = $this->db->query('findByFieldName', array('= a'), $this->model);
$expected = array('TestModel.field_name' => '= = a'); $expected = array('TestModel.field_name' => '= = a');
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->db->query('findByFieldName', array(), $this->model);
$expected = false;
$this->assertEqual($result, $expected);
} }
function testOrderParsing() { function testOrderParsing() {