Skip to content

Commit

Permalink
Changing to read Model.field from the start of string.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 28, 2010
1 parent ab8d77a commit 67b2cab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/behaviors/super_find.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ function superFind(&$Model, $conditions = null, $fields = array(), $order = null
if (is_string($key)) {
$check = $key;
}
if (strpos($check, '.') === false) {
if (!preg_match('/^(\w+)\.(\w+)/', $check, $matches)) {
continue;
}
list($modelName, $fieldName) = explode('.', $check, 2);
list(, $modelName, $fieldName) = $matches;
if ($modelName === $Model->alias || isset($Model->belongsTo[$modelName]) || isset($Model->hasOne[$modelName])) {
continue;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/models/behaviors/super_find.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ function testConditionsOfHABTMAndHasMany() {
));
$this->assertEqual($result, $expected);
}

/**
* testVarious
*
* @access public
* @return void
*/
function testVarious() {
$result = $this->User->superFind('all', array('conditions' => array('name = "User.1"')));
$expected = array();
$this->assertIdentical($result, $expected);
}
}

?>

0 comments on commit 67b2cab

Please sign in to comment.