Skip to content

Commit

Permalink
Avoiding table field name collisions while searching for associated d…
Browse files Browse the repository at this point in the history
…ata by primary key
  • Loading branch information
mylux committed Mar 17, 2015
1 parent 93105f8 commit 266f6d2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ORM/Marshaller.php
Expand Up @@ -108,9 +108,10 @@ public function one(array $data, array $options = [])
$primaryKey = $schema->primaryKey();

if (array_intersect($primaryKey, array_keys($data)) == $primaryKey) {
$tableName=$this->_table->table();
$record = $this->_table->find('all');
foreach ($primaryKey as $pkey) {
$record->where(["$pkey" => $data[$pkey] ]);
$record->where(["$tableName.$pkey" => $data[$pkey] ]);
}

$record = $record->first();
Expand Down

0 comments on commit 266f6d2

Please sign in to comment.