コード例 #1
0
ファイル: Model.php プロジェクト: phwoolcon/phwoolcon
 protected function _exists(PhalconModel\MetaDataInterface $metaData, AdapterInterface $connection, $table = null)
 {
     if ($this->_isNew) {
         return parent::_exists($metaData, $connection, $table);
     }
     // Be able to update primary keys
     $primaryValues = [];
     foreach ($metaData->getPrimaryKeyAttributes($this) as $field) {
         $primaryValues[$field] = [$oldValue = fnGet($this->_snapshot, $field), $this->{$field}];
         $this->{$field} = $oldValue;
     }
     $result = parent::_exists($metaData, $connection, $table);
     foreach ($primaryValues as $field => $values) {
         $this->{$field} = $values[1];
     }
     return $result;
 }
コード例 #2
0
ファイル: Base.php プロジェクト: bullhorn/fast-rest
 /**
  * Checks if this class exists in the database
  * @return bool
  */
 public function inDatabase()
 {
     return parent::_exists($this->getModelsMetaData(), $this->selectReadConnection());
 }