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


PHP Insert::into方法代码示例

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


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

示例1: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => 'pierre.rambaud86@gmail.com', 'login' => 'test', 'user_acl_role_id' => 1));
     $this->user->setPassword('test');
     $this->user->save();
     $this->object = Model::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->object->save();
     $this->documentTypeChildren = Model::fromArray(array('name' => 'Document Type children Name', 'description' => 'Document Type children description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentTypeChildren->save();
     $insert = new Insert();
     $insert->into('document_type_dependency')->values(array('parent_id' => $this->object->getId(), 'children_id' => $this->documentTypeChildren->getId()));
     $this->object->execute($insert);
     $insert = new Insert();
     $insert->into('document_type_view')->values(array('view_id' => $this->view->getId(), 'document_type_id' => $this->object->getId()));
     $this->object->execute($insert);
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:26,代码来源:ModelTest.php

示例2: testGetSqlString

 /**
  * @covers Zend\Db\Sql\Insert::getSqlString
  * @todo   Implement testGetSqlString().
  */
 public function testGetSqlString()
 {
     $this->insert->into('foo')->values(array('bar' => 'baz', 'boo' => new Expression('NOW()')));
     $this->assertEquals('INSERT INTO "foo" ("bar", "boo") VALUES (\'baz\', NOW())', $this->insert->getSqlString());
 }
开发者ID:Rovak,项目名称:zf2,代码行数:9,代码来源:InsertTest.php

示例3: 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

示例4: contactInsert

 /**
  * Build a sql object to insert a contact request record
  *
  * @param ContactEntity $contact
  * @return Insert
  */
 protected function contactInsert(ContactEntity $contact)
 {
     $insert = new Insert();
     $insert->into('contact_request')->values(['name' => $contact->getName(), 'email' => $contact->getEmail(), 'message' => $contact->getMessage()]);
     return $insert;
 }
开发者ID:pdizz,项目名称:pdizz-web,代码行数:12,代码来源:ContactService.php

示例5: testValuesMerge

 /**
  * @group ZF2-536
  */
 public function testValuesMerge()
 {
     $this->insert->into('foo')->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null));
     $this->insert->into('foo')->values(array('qux' => 100), Insert::VALUES_MERGE);
     $this->assertEquals('INSERT INTO "foo" ("bar", "boo", "bam", "qux") VALUES (\'baz\', NOW(), NULL, \'100\')', $this->insert->getSqlString(new TrustingSql92Platform()));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:9,代码来源:InsertTest.php

示例6: getPostInsert

 /**
  * Get a sql object to insert a new blog post
  *
  * @param PostEntity $post
  * @return Insert
  */
 protected function getPostInsert(PostEntity $post)
 {
     $insert = new Insert();
     $insert->into(new TableIdentifier('blog_post'))->values(['title' => $post->getTitle(), 'author' => $post->getAuthor(), 'content' => $post->getContent(), 'is_visible' => $post->getIsVisible()]);
     return $insert;
 }
开发者ID:pdizz,项目名称:pdizz-web,代码行数:12,代码来源:PostService.php

示例7: assetInsert

 /**
  * Build a sql object to insert a new blog post asset
  *
  * @param AssetEntity $asset
  * @return Insert
  */
 protected function assetInsert(AssetEntity $asset)
 {
     $insert = new Insert();
     $insert->into(new TableIdentifier('blog_asset'))->values(['blog_post_id' => $asset->getBlogPostId(), 'directory' => $asset->getDirectory(), 'baseurl' => $asset->getBaseurl(), 'filename' => $asset->getFilename()]);
     return $insert;
 }
开发者ID:pdizz,项目名称:pdizz-web,代码行数:12,代码来源:AssetService.php

示例8: install

 /**
  * Install module
  *
  * @param ModuleManager $moduleManager Module manager
  * @param string        $moduleName    Module Name
  *
  * @return boolean|integer
  */
 public static function install(ModuleManager $moduleManager, $moduleName)
 {
     try {
         $object = $moduleManager->loadModule($moduleName);
     } catch (\Exception $e) {
         //Don't care
     }
     if (empty($object) or !$object->install()) {
         return false;
     }
     $model = new Model();
     $model->setName($moduleName);
     $model->save();
     $select = new Sql\Select();
     $select->from('user_acl_resource')->columns(array('id'))->where->equalTo('resource', 'modules');
     $insert = new Sql\Insert();
     $insert->into('user_acl_permission')->values(array('permission' => $moduleName, 'user_acl_resource_id' => $model->fetchOne($select)));
     $model->execute($insert);
     return $model->getId();
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:28,代码来源:Model.php

示例9: save

 /**
  * Save properties
  *
  * @return boolean
  */
 public function save()
 {
     $this->events()->trigger(__CLASS__, 'before.save', $this);
     if (!empty($this->data['document_type_id'])) {
         $this->delete();
         $insert = new Insert();
         $insert->into('document_type_view');
         foreach ($this->getElements() as $view) {
             $insert->values(array('document_type_id' => $this->getDocumentTypeId(), 'view_id' => $view->getId()));
             $this->execute($insert);
         }
         $this->events()->trigger(__CLASS__, 'after.save', $this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.save.failed', $this);
     return false;
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:22,代码来源:Collection.php

示例10: save

 /**
  * Save document type model
  *
  * @return integer
  */
 public function save()
 {
     $this->events()->trigger(__CLASS__, 'before.save', $this);
     $arraySave = array('name' => $this->getName(), 'updated_at' => new Expression('NOW()'), 'description' => $this->getDescription(), 'icon_id' => $this->getIconId(), 'default_view_id' => $this->getDefaultViewId(), 'user_id' => $this->getUserId());
     try {
         $id = $this->getId();
         if (empty($id)) {
             $arraySave['created_at'] = new Expression('NOW()');
             $this->insert($arraySave);
             $this->setId($this->getLastInsertId());
         } else {
             $this->update($arraySave, array('id' => (int) $this->getId()));
         }
         $delete = new Sql\Delete();
         $delete->from('document_type_view');
         $delete->where(array('document_type_id' => (int) $this->getId()));
         $this->execute($delete);
         foreach ($this->views as $viewId) {
             if (empty($viewId)) {
                 continue;
             }
             $insert = new Sql\Insert();
             $insert->into('document_type_view')->values(array('document_type_id' => $this->getId(), 'view_id' => $viewId));
             $this->execute($insert);
         }
         $delete = new Sql\Delete();
         $delete->from('document_type_dependency');
         $delete->where->equalTo('parent_id', (int) $this->getId());
         $this->execute($delete);
         $dependencies = $this->getDependencies();
         if (!empty($dependencies)) {
             foreach ($dependencies as $childrenId) {
                 $insert = new Sql\Insert();
                 $insert->into('document_type_dependency')->values(array('parent_id' => $this->getId(), 'children_id' => $childrenId));
                 $this->execute($insert);
             }
         }
         $this->events()->trigger(__CLASS__, 'after.save', $this);
         return $this->getId();
     } catch (\Exception $e) {
         $this->events()->trigger(__CLASS__, 'after.save.failed', $this);
         throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:49,代码来源:Model.php

示例11: setValue

 /**
  * Set config value
  *
  * @param string $source       Source
  * @param array  $destinations Destinations
  *
  * @return boolean
  */
 public function setValue($source, array $destinations)
 {
     if (is_numeric($source)) {
         $row = $this->fetchRow($this->select(array('id' => $source)));
         if (empty($row)) {
             return false;
         }
         $sourceId = $row['id'];
     } else {
         $row = $this->fetchRow($this->select(array('source' => $source)));
         if (!empty($row)) {
             $sourceId = $row['id'];
         } else {
             $this->insert(array('source' => $source));
             $sourceId = $this->getLastInsertId();
         }
     }
     foreach ($destinations as $destination) {
         if (empty($destination['locale']) or empty($destination['value'])) {
             continue;
         }
         $select = new Select();
         $select->from('core_translate_locale');
         $select->where->equalTo('locale', $destination['locale']);
         $select->where->equalTo('core_translate_id', $sourceId);
         $row = $this->fetchRow($select);
         if (!empty($row)) {
             $destination['dst_id'] = $row['id'];
         }
         if (!empty($destination['dst_id'])) {
             $update = new Update('core_translate_locale');
             $update->set(array('destination' => $destination['value'], 'locale' => $destination['locale']));
             $update->where->equalTo('id', $destination['dst_id']);
             $this->execute($update);
         } else {
             $insert = new Insert();
             $insert->into('core_translate_locale')->values(array('destination' => $destination['value'], 'locale' => $destination['locale'], 'core_translate_id' => $sourceId));
             $this->execute($insert);
         }
     }
     return true;
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:50,代码来源:Translator.php

示例12: getUrlId

 /**
  * Get url id
  *
  * @param string $requestUri Request URI
  * @param string $referer    Referer
  *
  * @return integer
  */
 public function getUrlId($requestUri, $referer)
 {
     $select = new Select();
     $select->from('log_url_info')->where->equalTo('url', $requestUri);
     if (is_null($referer)) {
         $select->where->isNull('referer');
     } else {
         $select->where->equalTo('referer', $referer);
     }
     $urlInfo = $this->fetchRow($select);
     if (!empty($urlInfo['id'])) {
         $urlId = $urlInfo['id'];
     } else {
         $insert = new Insert();
         $insert->into('log_url_info')->values(array('url' => $requestUri, 'referer' => $referer));
         $this->execute($insert);
         $urlId = $this->getLastInsertId('log_url_info');
     }
     return $urlId;
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:28,代码来源:Visitor.php


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