/**
  * {@inheritdoc}
  */
 public function insertAndGetId(Query $query, array $values, $primaryKey = null)
 {
     if ($query->insert($values) === false) {
         return false;
     }
     return $query->getConnection()->getPDO()->lastInsertId();
 }
 /**
  * {@inheritdoc}
  */
 public function insertAndGetId(Query $query, array $values, $primaryKey = null)
 {
     if ($query->insert($values) === false) {
         return false;
     }
     $sequence = $query->getTable() . '_' . $primaryKey . '_seq';
     return $query->getConnection()->getPDO()->lastInsertId($sequence);
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function insert(array $values)
 {
     // Execute "beforeInsert" hooks
     foreach ($this->model->getHooks('beforeInsert') as $hook) {
         $values = $hook($values, $this);
     }
     // Insert record
     $inserted = parent::insert($values);
     // Execute "afterInsert" hooks
     foreach ($this->model->getHooks('afterInsert') as $hook) {
         $hook($inserted);
     }
     // Return insert status
     return $inserted;
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function insert(array $values)
 {
     if ($this->model->isReadOnly()) {
         throw new ReadOnlyRecordException(vsprintf("%s(): Attempted to create a read-only record.", [__METHOD__]));
     }
     // Execute "beforeInsert" hooks
     foreach ($this->model->getHooks('beforeInsert') as $hook) {
         $values = $hook($values, $this);
     }
     // Insert record
     $inserted = parent::insert($values);
     // Execute "afterInsert" hooks
     foreach ($this->model->getHooks('afterInsert') as $hook) {
         $hook($inserted);
     }
     // Return insert status
     return $inserted;
 }