merging changes from source:whiteboard/sandbox/phpnut/pre_0.9.2 in revisions [343] and [344]

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@345 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-07-10 07:49:30 +00:00
parent 6460f6e83f
commit 3c5c99423d
2 changed files with 4 additions and 10 deletions

View file

@ -379,7 +379,7 @@ class DBO extends Object
function hasAny($table, $sql)
{
$out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":""));
return is_array($out)? $out['count']: false;
return is_array($out)? $out[0]['count']: false;
}
/**

View file

@ -325,10 +325,9 @@ class Model extends Object
break;
}
if(!is_a($this->$className, $className))
if(!isset($this->$className))
{
$this->$className = new $className();
}
$this->{$joinedHas}[] = $this->$className;
$this->relink();
@ -603,15 +602,10 @@ class Model extends Object
$fields[] = 'modified';
$values[] = 'NOW()';
}
$out = $this->db->one("SELECT COUNT(*) AS count FROM {$this->table} WHERE id = '{$this->id}'");
if(empty($out[0]['count']))
if(!$this->exists())
{
$this->id = false;
}
if(count($fields))
{
if(!empty($this->id)){