当前位置: 首页>>代码示例>>PHP>>正文


PHP Insert::getRawState方法代码示例

本文整理汇总了PHP中Zend\Db\Sql\Insert::getRawState方法的典型用法代码示例。如果您正苦于以下问题:PHP Insert::getRawState方法的具体用法?PHP Insert::getRawState怎么用?PHP Insert::getRawState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Db\Sql\Insert的用法示例。


在下文中一共展示了Insert::getRawState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preInsert

 /**
  * @param Insert $insert
  */
 public function preInsert(Insert $insert)
 {
     $metaColumns = $this->tableGateway->getColumns();
     if (count($metaColumns)) {
         $metaColumns = array_flip($metaColumns);
         $columns = array_flip($insert->getRawState('columns'));
         $columns = array_flip(array_intersect_key($columns, $metaColumns));
         $values = $insert->getRawState('values');
         $values = array_intersect_key($values, $columns);
         $insert->values(array_values($values));
         $insert->columns(array_values($columns));
     }
 }
开发者ID:zfstarter,项目名称:zfs-domain-model,代码行数:16,代码来源:FilterColumnsFeature.php

示例2: preInsert

 /**
  * @param  Insert $insert
  */
 public function preInsert(Insert $insert)
 {
     $columns = $insert->getRawState('columns');
     $values = $insert->getRawState('values');
     $key = array_search($this->primaryKeyField, $columns);
     if ($key !== false) {
         $this->sequenceValue = $values[$key];
         return $insert;
     }
     $this->sequenceValue = $this->nextSequenceId();
     if ($this->sequenceValue === null) {
         return $insert;
     }
     $insert->values(array($this->primaryKeyField => $this->sequenceValue), Insert::VALUES_MERGE);
     return $insert;
 }
开发者ID:eltonoliveira,项目名称:jenkins,代码行数:19,代码来源:SequenceFeature.php

示例3: preInsert

 public function preInsert(Insert $insert)
 {
     $columns = $insert->getRawState('columns');
     $values = $insert->getRawState('values');
     $key = array_search($this->primaryKeyField, $columns);
     if ($key !== false) {
         $this->sequenceValue = $values[$key];
         return $insert;
     }
     $this->sequenceValue = $this->nextSequenceId();
     if ($this->sequenceValue === null) {
         return $insert;
     }
     array_push($columns, $this->primaryKeyField);
     array_push($values, $this->sequenceValue);
     $insert->columns($columns);
     $insert->values($values);
     return $insert;
 }
开发者ID:Yansor,项目名称:yafblog,代码行数:19,代码来源:SequenceFeature.php

示例4: executeInsert

 /**
  * @param Insert $insert
  * @return mixed
  * @throws \Directus\Acl\Exception\UnauthorizedTableAddException
  * @throws \Directus\Acl\Exception\UnauthorizedFieldWriteException
  */
 protected function executeInsert(Insert $insert)
 {
     /**
      * ACL Enforcement
      */
     $insertState = $insert->getRawState();
     $insertTable = $this->getRawTableNameFromQueryStateTable($insertState['table']);
     if (!$this->acl->hasTablePrivilege($insertTable, 'add')) {
         $aclErrorPrefix = $this->acl->getErrorMessagePrefix();
         throw new UnauthorizedTableAddException($aclErrorPrefix . "Table add access forbidden on table {$insertTable}");
     }
     // Enforce write field blacklist (if user lacks bigedit privileges on this table)
     if (!$this->acl->hasTablePrivilege($insertTable, 'bigedit')) {
         $this->acl->enforceBlacklist($insertTable, $insertState['columns'], Acl::FIELD_WRITE_BLACKLIST);
     }
     try {
         return parent::executeInsert($insert);
     } catch (\Zend\Db\Adapter\Exception\InvalidQueryException $e) {
         if ('production' !== DIRECTUS_ENV) {
             if (strpos(strtolower($e->getMessage()), 'duplicate entry') !== FALSE) {
                 throw new DuplicateEntryException($e->getMessage());
             }
             throw new \RuntimeException("This query failed: " . $this->dumpSql($insert), 0, $e);
         }
         // @todo send developer warning
         throw $e;
     }
 }
开发者ID:rudderdon,项目名称:Directus,代码行数:34,代码来源:AclAwareTableGateway.php

示例5: executeInsert

 /**
  * @todo add $columns support
  *
  * @param Insert $insert
  * @return mixed
  * @throws Exception\RuntimeException
  */
 protected function executeInsert(Insert $insert)
 {
     $insertState = $insert->getRawState();
     if ($insertState['table'] != $this->table) {
         throw new Exception\RuntimeException('The table name of the provided Insert object must match that of the table');
     }
     // apply preInsert features
     $this->featureSet->apply('preInsert', array($insert));
     $statement = $this->sql->prepareStatementForSqlObject($insert);
     $result = $statement->execute();
     $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     // apply postInsert features
     $this->featureSet->apply('postInsert', array($statement, $result));
     return $result->getAffectedRows();
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:22,代码来源:AbstractTableGateway.php

示例6: executeInsert

 /**
  * @todo add $columns support
  *
  * @param Insert $insert
  * @return int
  * @throws Exception\RuntimeException
  */
 protected function executeInsert(Insert $insert)
 {
     $insertState = $insert->getRawState();
     if ($insertState['table'] != $this->table) {
         throw new Exception\RuntimeException('The table name of the provided Insert object must match that of the table');
     }
     // apply preInsert features
     $this->featureSet->apply(EventFeatureEventsInterface::EVENT_PRE_INSERT, [$insert]);
     // Most RDBMS solutions do not allow using table aliases in INSERTs
     // See https://github.com/zendframework/zf2/issues/7311
     $unaliasedTable = false;
     if (is_array($insertState['table'])) {
         $tableData = array_values($insertState['table']);
         $unaliasedTable = array_shift($tableData);
         $insert->into($unaliasedTable);
     }
     $statement = $this->sql->prepareStatementForSqlObject($insert);
     $result = $statement->execute();
     $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     // apply postInsert features
     $this->featureSet->apply(EventFeatureEventsInterface::EVENT_POST_INSERT, [$statement, $result]);
     // Reset original table information in Insert instance, if necessary
     if ($unaliasedTable) {
         $insert->into($insertState['table']);
     }
     return $result->getAffectedRows();
 }
开发者ID:zendframework,项目名称:zend-db,代码行数:34,代码来源:AbstractTableGateway.php

示例7: executeInsert

 /**
  * @param Insert $insert
  * @return mixed
  * @throws \Directus\Acl\Exception\UnauthorizedTableAddException
  * @throws \Directus\Acl\Exception\UnauthorizedFieldWriteException
  */
 protected function executeInsert(Insert $insert)
 {
     /**
      * ACL Enforcement
      */
     $insertState = $insert->getRawState();
     $insertTable = $this->getRawTableNameFromQueryStateTable($insertState['table']);
     $insertData = $insertState['values'];
     if (!$this->acl->hasTablePrivilege($insertTable, 'add')) {
         $aclErrorPrefix = $this->acl->getErrorMessagePrefix();
         throw new UnauthorizedTableAddException($aclErrorPrefix . 'Table add access forbidden on table ' . $insertTable);
     }
     // Enforce write field blacklist
     $this->acl->enforceBlacklist($insertTable, $insertState['columns'], Acl::FIELD_WRITE_BLACKLIST);
     try {
         // Data to be inserted with the column name as assoc key.
         $insertDataAssoc = array_combine($insertState['columns'], $insertData);
         $this->emitter->run('table.insert:before', [$insertTable, $insertDataAssoc]);
         $this->emitter->run('table.insert.' . $insertTable . ':before', [$insertDataAssoc]);
         $result = parent::executeInsert($insert);
         $insertTableGateway = new self($this->acl, $insertTable, $this->adapter);
         $resultData = $insertTableGateway->find($this->getLastInsertValue());
         $this->emitter->run('table.insert', [$insertTable, $resultData]);
         $this->emitter->run('table.insert.' . $insertTable, [$resultData]);
         $this->emitter->run('table.insert:after', [$insertTable, $resultData]);
         $this->emitter->run('table.insert.' . $insertTable . ':after', [$resultData]);
         return $result;
     } catch (\Zend\Db\Adapter\Exception\InvalidQueryException $e) {
         // @todo send developer warning
         if (strpos(strtolower($e->getMessage()), 'duplicate entry') !== FALSE) {
             throw new DuplicateEntryException($e->getMessage());
         }
         if ('production' !== DIRECTUS_ENV) {
             throw new \RuntimeException('This query failed: ' . $this->dumpSql($insert), 0, $e);
         }
         throw $e;
     }
 }
开发者ID:YounessTayer,项目名称:directus,代码行数:44,代码来源:AclAwareTableGateway.php


注:本文中的Zend\Db\Sql\Insert::getRawState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。