BUGFIX Reset WHERE clause in SQLMap->getItem() to ensure it can be invoked more than once

This commit is contained in:
Ingo Schommer 2011-09-14 10:57:29 +02:00
parent b438a0a095
commit 55183ec386

View File

@ -38,8 +38,10 @@ class SQLMap extends Object implements IteratorAggregate {
public function getItem($id) { public function getItem($id) {
if($id) { if($id) {
$baseTable = reset($this->query->from); $baseTable = reset($this->query->from);
$this->query->where[] = "$baseTable.\"ID\" = $id"; $where = "$baseTable.\"ID\" = $id";
$this->query->where[sha1($where)] = $where;
$record = $this->query->execute()->first(); $record = $this->query->execute()->first();
unset($this->query->where[sha1($where)]);
if($record) { if($record) {
$className = $record['ClassName']; $className = $record['ClassName'];
$obj = new $className($record); $obj = new $className($record);