コード例 #1
0
ファイル: Table.php プロジェクト: ankaau/GathBandhan
 /**
  * If a table key (id) is NULL : inserts a new row
  * otherwise updates existing row in the database table
  * If table has a single primary key, updates the primary key in $this with the new value
  *
  * Can be overridden or overloaded by the child class
  *
  * @param  boolean  $updateNulls  TRUE: null object variables are also updated, FALSE: not.
  * @return boolean                TRUE if successful otherwise FALSE
  *
  * @throws \RuntimeException
  */
 public function store($updateNulls = false)
 {
     $primaryKeys = array_keys($this->getPrimaryKeysTypes());
     if ($this->hasPrimaryKey()) {
         $ok = $this->_db->updateObject($this->_tbl, $this, $primaryKeys, $updateNulls);
     } else {
         if (count($primaryKeys) == 1) {
             $primaryKeys = $primaryKeys[0];
         }
         $ok = $this->_db->insertObject($this->_tbl, $this, $primaryKeys);
     }
     if (!$ok) {
         $this->_error = strtolower(get_class($this)) . "::store failed: " . $this->_db->getErrorMsg();
     }
     return $ok;
 }