ORM: Allow to search for any ID, but never assign it until successful
/trunk/Model.php |
---|
135,10 → 135,17 |
* @return Model|null |
* This object filled with missing data, or <code>null</code> |
* if there is no data for this object |
* @see Table::find(Model) |
*/ |
public function find ($id = null) |
{ |
$class = \get_class($this); |
if ($id === null) |
{ |
$id = $this->{$class::$_persistentId}; |
} |
$result = $this->persistentTable->find($id); |
if ($id !== null) |
{ |
$this->{$class::$_persistentId} = $id; |