mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 18:12:40 +00:00
Refactoring DboSource::update(), and adding magic finder method fix for Ticket #1673
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3955 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e8222444b8
commit
e955f3fd65
1 changed files with 5 additions and 9 deletions
|
@ -209,7 +209,7 @@ class DboSource extends DataSource {
|
|||
$c = 0;
|
||||
$query = array();
|
||||
foreach ($field as $f) {
|
||||
$query[$args[2]->name . '.' . $f] = $params[$c++];
|
||||
$query[$args[2]->name . '.' . $f] = '= ' . $params[$c++];
|
||||
}
|
||||
|
||||
if ($or) {
|
||||
|
@ -1193,15 +1193,11 @@ class DboSource extends DataSource {
|
|||
$updates[] = $update;
|
||||
}
|
||||
}
|
||||
$sql = 'UPDATE ' . $this->fullTableName($model);
|
||||
$sql .= ' SET ' . join(',', $updates);
|
||||
|
||||
if ($conditions == null) {
|
||||
$sql .= ' WHERE ' . $this->name($model->primaryKey) . ' = ' . $this->value($model->getID(), $model->getColumnType($model->primaryKey));
|
||||
} else {
|
||||
$sql .= $this->conditions($conditions);
|
||||
$conditions = array($model->primaryKey => $model->getID());
|
||||
}
|
||||
if (!$this->execute($sql)) {
|
||||
|
||||
if (!$this->execute('UPDATE '.$this->fullTableName($model).' SET '.join(',', $updates).$this->conditions($conditions))) {
|
||||
$model->onError();
|
||||
return false;
|
||||
}
|
||||
|
@ -1215,7 +1211,7 @@ class DboSource extends DataSource {
|
|||
* @param mixed $conditions
|
||||
* @return boolean Success
|
||||
*/
|
||||
function delete(&$model, $id = null, $conditions = null) {
|
||||
function delete(&$model, $conditions = null) {
|
||||
$_id = $model->id;
|
||||
if ($id != null) {
|
||||
$model->id = $id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue