Refactoring set() method into Object, and adding $conditiions === true translation in DboSource

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4475 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-02-08 17:33:59 +00:00
parent f377ed6d2a
commit 15f7509171
3 changed files with 21 additions and 21 deletions

View file

@ -494,24 +494,6 @@ class AuthComponent extends Object {
return null;
}
}
/**
* Allows setting of multiple properties of AuthComponent in a single line of code.
*
* @access public
* @param array $properties An associative array containing AuthComponent
* properties and corresponding values.
* @return void
*/
function set($properties = array()) {
if (is_array($properties) && !empty($properties)) {
$vars = get_object_vars($this);
foreach ($properties as $key => $val) {
if (array_key_exists($key, $vars)) {
$this->{$key} = $val;
}
}
}
}
/**
* Component shutdown. If user is logged in, wipe out redirect.
*

View file

@ -1326,8 +1326,8 @@ class DboSource extends DataSource {
}
}
if (is_string($conditions)) {
if (trim($conditions) == '') {
if (is_string($conditions) || empty($conditions) || $conditions === true) {
if (empty($conditions) || trim($conditions) == '' || $conditions === true) {
$conditions = ' 1 = 1';
} else {
$start = null;
@ -1365,7 +1365,7 @@ class DboSource extends DataSource {
$clause = ' WHERE ';
$out = $this->conditionKeysToString($conditions);
if (empty($out)) {
return $clause . ' (1 = 1)';
return $clause . ' 1 = 1';
}
return $clause . ' (' . join(') AND (', $out) . ')';
}

View file

@ -188,6 +188,24 @@ class Object{
}
return join("\n", $back);
}
/**
* Allows setting of multiple properties of the object in a single line of code.
*
* @access public
* @param array $properties An associative array containing AuthComponent
* properties and corresponding values.
* @return void
*/
function set($properties = array()) {
if (is_array($properties) && !empty($properties)) {
$vars = get_object_vars($this);
foreach ($properties as $key => $val) {
if (array_key_exists($key, $vars)) {
$this->{$key} = $val;
}
}
}
}
/**
* Used to report user friendly errors.
* If there is a file app/error.php this file will be loaded