mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Reset WHERE clause in SQLMap->getItem() to ensure it can be invoked more than once
This commit is contained in:
parent
b438a0a095
commit
55183ec386
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user