Merging fixes and enhancements into trunk.

Revision: [2170]
Adding column formatting for create() and update()
This is also a fix for Ticket #450




git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2171 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-03-01 21:24:19 +00:00
parent 9c5e3bb979
commit 26fbf4a287
2 changed files with 8 additions and 5 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.8.2169
0.10.8.2171

View file

@ -353,9 +353,11 @@ class DboSource extends DataSource
$fieldInsert[] = $this->name($field);
}
$count = 0;
foreach ($values as $value)
{
$valueInsert[] = $this->value($value);
$valueInsert[] = $this->value($value, $model->getColumnType($fields[$count]));
$count++;
}
if($this->execute('INSERT INTO '.$model->table.' ('.join(',', $fieldInsert).') VALUES ('.join(',', $valueInsert).')'))
@ -847,14 +849,15 @@ class DboSource extends DataSource
function update (&$model, $fields = null, $values = null)
{
$updates = array();
foreach (array_combine($fields, $values) as $field => $value)
$combined = array_combine($fields, $values);
foreach ($combined as $field => $value)
{
$updates[] = $this->name($field).'='.$this->value($value);
$updates[] = $this->name($field).'='.$this->value($value, $model->getColumnType($field));
}
$sql = 'UPDATE '.$this->name($model->table);
$sql .= ' SET '.join(',', $updates);
$sql .= ' WHERE '.$this->name($model->primaryKey).'='.$this->value($model->getID());
$sql .= ' WHERE '.$this->name($model->primaryKey).'='.$this->value($model->getID(), $model->getColumnType($model->primaryKey));
return $this->execute($sql);
}