Refactoring the Model::_ _saveMulti() to use one INSERT statement instead of looping over each value and querying INSERT.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5366 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-06-28 06:46:26 +00:00
parent 2c7f16d1f1
commit 2e54eb1706

View file

@ -1134,9 +1134,15 @@ class Model extends Overloadable {
if (!empty($newValue[$loopAssoc])) {
$secondCount = count($newValue[$loopAssoc]);
$insertValues = null;
for ($x = 0; $x < $secondCount; $x++) {
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$newValue[$loopAssoc][$x]}");
$insertValues .= $newValue[$loopAssoc][$x];
if($x < $secondCount - 1) {
$insertValues .= ', ';
}
}
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$insertValues};");
}
}
}