Exemple #1
0
 /**
  * Reload info from DB for current object. Will also call afterLoad method in case updates are needed.
  */
 public function reload()
 {
     $this->_relations = array();
     if (is_array($this->_pk)) {
         $c = $p = [];
         foreach ($this->_originalPk as $k => $v) {
             $c[] = "`{$k}` = :pk_{$k}";
             $p[":pk_{$k}"] = $v;
         }
         $this->_attributes = $this->_db->table($this->_tableName)->where(implode(" AND ", $c), $p)->first();
     } else {
         $this->_attributes = $this->_db->table($this->_tableName)->where("`{$this->_pk}` = :__pk")->setParam(':__pk', $this->_originalPk)->first();
     }
     $this->_updatedAttributes = [];
     $this->afterLoad();
 }