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


PHP Insert::values方法代码示例

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


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

示例1: testValues

 /**
  * @covers Zend\Db\Sql\Insert::values
  */
 public function testValues()
 {
     $this->insert->values(array('foo' => 'bar'));
     $this->assertEquals(array('foo'), $this->readAttribute($this->insert, 'columns'));
     $this->assertEquals(array('bar'), $this->readAttribute($this->insert, 'values'));
     // test will merge cols and values of previously set stuff
     $this->insert->values(array('foo' => 'bax'), Insert::VALUES_MERGE);
     $this->insert->values(array('boom' => 'bam'), Insert::VALUES_MERGE);
     $this->assertEquals(array('foo', 'boom'), $this->readAttribute($this->insert, 'columns'));
     $this->assertEquals(array('bax', 'bam'), $this->readAttribute($this->insert, 'values'));
     $this->insert->values(array('foo' => 'bax'));
     $this->assertEquals(array('foo'), $this->readAttribute($this->insert, 'columns'));
     $this->assertEquals(array('bax'), $this->readAttribute($this->insert, 'values'));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:17,代码来源:InsertTest.php

示例2: setRequest

 public function setRequest($id)
 {
     if ($id == $this->user_id) {
         return true;
     }
     $user = $this->getUserById($id);
     if (is_array($user)) {
         if ($user["friendship"] == -1) {
             //insert
             $insert = new Insert('fg_friends');
             $newData = array('user_one' => $this->user_id, 'user_two' => $id, 'state' => '0');
             $insert->values($newData);
             $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($insert);
             $resultSet = $statement->execute();
         } else {
             if (!$user["i_am_adder"] && $user["friendship"] == 0) {
                 //update
                 $update = new Update('fg_friends');
                 $newData = array('state' => '1');
                 $update->set($newData);
                 $update->where(array('user_one' => $id, 'user_two' => $this->user_id));
                 $statement = $this->tableGateway->getSql()->prepareStatementForSqlObject($update);
                 $resultSet = $statement->execute();
             }
         }
         return true;
     }
     return false;
 }
开发者ID:benjaminchazelle,项目名称:csZendApplication,代码行数:29,代码来源:FriendTable.php

示例3: insertBookmark

 public function insertBookmark($payload)
 {
     $insert = new Insert($this->table);
     $insert->values($payload);
     $this->insertWith($insert);
     return $this->lastInsertValue;
 }
开发者ID:rudderdon,项目名称:Directus,代码行数:7,代码来源:DirectusBookmarksTableGateway.php

示例4: constructPreferences

 public function constructPreferences($user_id, $table, $preferences = null, $title = null)
 {
     if ($preferences) {
         $newPreferencesData = false;
         // @todo enforce non-empty set
         if (empty($preferences['columns_visible'])) {
             $newPreferencesData = true;
             $columns_visible = TableSchema::getTableColumns($table, 6);
             $preferences['columns_visible'] = implode(',', $columns_visible);
         }
         $preferencesDefaultsApplied = $this->applyDefaultPreferences($table, $preferences);
         if (count(array_diff($preferences, $preferencesDefaultsApplied))) {
             $newPreferencesData = true;
         }
         $preferences = $preferencesDefaultsApplied;
         if ($newPreferencesData) {
             $id = $this->addOrUpdateRecordByArray($preferences);
         }
         return $preferences;
     }
     $insert = new Insert($this->table);
     // User doesn't have any preferences for this table yet. Please create!
     $columns_visible = TableSchema::getTableColumns($table, 6);
     $data = array('user' => $user_id, 'columns_visible' => implode(',', $columns_visible), 'table_name' => $table, 'title' => $title);
     if (TableSchema::hasTableColumn($table, 'sort')) {
         $data['sort'] = 'sort';
     }
     $data = $this->applyDefaultPreferences($table, $data);
     $insert->values($data);
     $this->insertWith($insert);
     return $data;
 }
开发者ID:nagelxz,项目名称:Directus,代码行数:32,代码来源:DirectusPreferencesTableGateway.php

示例5: save

 public function save(\Api\Entity\Post $post)
 {
     $hydrator = $this->getHydrator();
     $action = null;
     $postData = array('title' => $post->getTitle(), 'description' => $post->getDescription());
     if ($post->getId()) {
         $action = new Update('posts');
         $action->set($postData);
         $action->where(array('id = ?' => $post->getId()));
     } else {
         $postData['author_id'] = $post->getAuthorId();
         $action = new Insert('posts');
         $action->values($postData);
     }
     $sql = new Sql($this->getAdaptor());
     $statement = $sql->prepareStatementForSqlObject($action);
     $result = $statement->execute();
     if ($result instanceof ResultInterface) {
         if ($pk = $result->getGeneratedValue()) {
             $post->setId($pk);
         }
         return $this->getPost($post->getId());
     }
     throw new \Exception('something went wrong.Please try again later');
 }
开发者ID:projectsmahendra,项目名称:blogger,代码行数:25,代码来源:PostService.php

示例6: save

 /**
  * {@inheritDoc}
  */
 public function save(PostInterface $postObject)
 {
     $postData = $this->hydrator->extract($postObject);
     unset($postData['id']);
     // Neither Insert nor Update needs the ID in the array
     if ($postObject->getId()) {
         // ID present, it's an Update
         $action = new Update('post');
         $action->set($postData);
         $action->where(array('id = ?' => $postObject->getId()));
     } else {
         // ID NOT present, it's an Insert
         $action = new Insert('post');
         $action->values($postData);
     }
     $sql = new Sql($this->dbAdapter);
     $stmt = $sql->prepareStatementForSqlObject($action);
     $result = $stmt->execute();
     if ($result instanceof ResultInterface) {
         if ($newId = $result->getGeneratedValue()) {
             // When a value has been generated, set it on the object
             $postObject->setId($newId);
         }
         return $postObject;
     }
     throw new \Exception("Database error");
 }
开发者ID:khanhdeux,项目名称:zend,代码行数:30,代码来源:ZendDbSqlMapper.php

示例7: exportInsert

 /**
  * Exports insert SQL.
  *
  * @param  array  $data
  * @return string
  */
 protected function exportInsert(array $data)
 {
     $insertSql = '';
     $insert = new Insert(self::TABLE_NAME);
     foreach ($data as $id => $value) {
         $insertSql .= @$insert->values(array('id' => $id, 'value' => $value))->getSqlString($this->getPlatform()) . ';' . PHP_EOL;
     }
     return $insertSql;
 }
开发者ID:umpirsky,项目名称:list-generator,代码行数:15,代码来源:SqlExporter.php

示例8: install

 public function install($config)
 {
     $dbinstall = new Dbinstall($config);
     $table_account = new CreateTable('account');
     $table_account->addColumn(new Column\Integer('id', FALSE, NULL, array('autoincrement' => true)))->addConstraint(new Constraint\PrimaryKey('id'))->addColumn(new Column\Varchar('username', 50, false))->addColumn(new Column\Varchar('password', 50, false))->addColumn(new Column\Varchar('email', 50, false))->addConstraint(new Constraint\UniqueKey('email'))->addColumn(new Column\Varchar('openid_qq', 100, true))->addConstraint(new Constraint\UniqueKey('openid_qq'))->addColumn(new Column\Varchar('openid_sina', 100, true))->addConstraint(new Constraint\UniqueKey('openid_sina'))->addColumn(new Column\Varchar('openid_wechat', 100, true))->addConstraint(new Constraint\UniqueKey('openid_wechat'))->addColumn(new Column\Integer('status', false, 0));
     $dbinstall->addCreateTable($table_account);
     $insert_account = new Insert('account');
     $insert_account->values(array('username' => 'admin', 'password' => 'admin', 'email' => '164713332@qq.com', 'status' => 1));
     $dbinstall->addInsert($insert_account);
     $dbinstall->install();
 }
开发者ID:solody,项目名称:solody,代码行数:11,代码来源:SolodyDbinstall.php

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

示例10: saveProduct

 public function saveProduct($productData)
 {
     $action = new Insert('products');
     $action->values($productData);
     $sql = new Sql($this->dbAdapter);
     $stmt = $sql->prepareStatementForSqlObject($action);
     $result = $stmt->execute();
     if ($result instanceof ResultInterface) {
         if ($newId = $result->getGeneratedValue()) {
             return $newId;
         }
         return true;
     }
     throw new \Exception('Database Error');
 }
开发者ID:anillaogi016,项目名称:zend-admin,代码行数:15,代码来源:ImageService.php

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

示例12: save

 public function save(RFollow $followObject)
 {
     $postData = $this->hydrator->extract($followObject);
     //           Debug::dump($postData);
     /*
      * 下面这两行一定记得自己加上去
      */
     $postData['userID'] = $followObject->getUser()->getUserID();
     //         unset($postData['secname']);//等到更改成类的时候需要利用php的特性改变成员变量的类型,class变成id
     //           unset($postData['username']);//虽然还是比较麻烦,但是只要写一个类就够了,不需要再unset这么多了。
     $action = new Insert('rfollow');
     $action->values($postData);
     $sql = new Sql($this->dbAdapter);
     $stmt = $sql->prepareStatementForSqlObject($action);
     $result = $stmt->execute();
 }
开发者ID:pengtt0119,项目名称:CotestWeb_,代码行数:16,代码来源:RFollowMapper.php

示例13: save

 public function save(\Api\Entity\User $user)
 {
     $hydrator = $this->getHydrator();
     $postData = array('display_name' => $user->getEmail(), 'password' => $user->getPassword());
     $postData = array_merge($postData, array('email' => $user->getEmail(), 'username' => $user->getUsername()));
     $insert = new Insert('user');
     $insert->values($postData);
     $sql = new Sql($this->getAdaptor());
     $statement = $sql->prepareStatementForSqlObject($insert);
     $result = $statement->execute();
     if ($result instanceof ResultInterface) {
         if ($pk = $result->getGeneratedValue()) {
             $user->setUserId($pk);
         }
         return $hydrator->extract($user);
     }
     throw new \Exception('something went wrong.Please try again later');
 }
开发者ID:projectsmahendra,项目名称:blogger,代码行数:18,代码来源:UserService.php

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

示例15: registerUserByLoginName

 /**
  * Method to Insert a new User into the Database
  * 
  * @param array $array
  * @return array
  */
 public function registerUserByLoginName($array)
 {
     $array["password"] = $this->passwordService->create($array["password"], $array["timestamp"]);
     $values["password"] = $array["password"];
     $values["loginName"] = $array["loginName"];
     $values["ingameName"] = $array["ingameName"];
     $values["timestamp"] = $array["timestamp"];
     $action = new Insert('tbluser');
     $action->values($values);
     $sql = new Sql($this->dbAdapter);
     $stmt = $sql->prepareStatementForSqlObject($action);
     $result = $stmt->execute();
     if ($result instanceof ResultInterface) {
         if ($newID = $result->getGeneratedValue()) {
             return array('registerSuccess' => true);
         }
     }
     return array('registerSuccess' => false, 'errors' => array('errorMessage' => 'Database error'));
 }
开发者ID:DieDreiTechGetiere,项目名称:LNSU-backend,代码行数:25,代码来源:UserTable.php


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