public function tryLoadAny() { if (!$this->persistence) { throw new Exception(['Model is not associated with any database']); } if ($this->loaded()) { $this->unload(); } $this->data = $this->persistence->tryLoadAny($this); if ($this->data) { $this->id = $this->data[$this->id_field]; $this->hook('afterLoad'); } else { $this->unload(); } return $this; }
public function testNakedExpression() { $db = new Persistence_SQL($this->db->connection); $m = new Model($db, false); $m->addExpression('x', '2+3'); $m->tryLoadAny(); $this->assertEquals(5, $m['x']); }