Пример #1
0
 /**
  * @param AbstractTable $table
  * @return $this
  */
 public function setupWithTable(AbstractTable $table)
 {
     $this->sql = $table->getSql();
     $adapter = $this->sql->getAdapter();
     $table = $table->getTable();
     $metadata = $adapter->getMetadata();
     $this->columns = array_keys($metadata->getColumns($table->getTable(), $table->getSchema()));
     $this->primaryKey = $metadata->getPrimarys($table->getTable(), $table->getSchema());
     return $this;
 }
 /**
  * @param Insert $insert
  * @return mixed
  * @throws Exception\RuntimeException
  */
 protected function executeInsert(Insert $insert)
 {
     $insertState = $insert->getRawState();
     if ((string) $insertState['table'] != (string) $this->table) {
         throw new Exception\RuntimeException('The table name of the provided Insert object must match that of the table');
     }
     $statement = $this->sql->prepareStatement($insert);
     $result = $statement->execute();
     $this->lastInsertValue = $this->sql->getAdapter()->getDriver()->getConnection()->getLastGeneratedValue();
     return $result->getAffectedRows();
 }