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


PHP Sql::insert方法代码示例

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


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

示例1: saveItem

 public function saveItem($arrParam = null, $options = null)
 {
     if ($options['task'] == 'add') {
         $sqlObj = new \Zend\Db\Sql\Sql($this->adapter);
         $insertObj = $sqlObj->insert('service_account_register');
         $insertObj->values($arrParam);
         $sqlString = $sqlObj->getSqlStringForSqlObject($insertObj);
         $this->adapter->query($sqlString)->execute();
     }
     if ($options['task'] == 'edit') {
         $this->tableGateway->update($arrParam, array('id' => $arrParam['id']));
     }
     if ($options['task'] == 'multi-status') {
         if (!empty($arrParam)) {
             foreach ($arrParam['id'] as $key => $value) {
                 if ($arrParam['type'] == 'multi-active') {
                     $status = 1;
                 }
                 if ($arrParam['type'] == 'multi-in-active') {
                     $status = 0;
                 }
                 $data = array('id' => $value, 'status' => $status);
                 $this->tableGateway->update($data, array('id' => $value));
             }
         }
     }
 }
开发者ID:quangdungninh,项目名称:zendvnteam,代码行数:27,代码来源:ServiceTable.php

示例2: insert

 public function insert($data)
 {
     $insert = $this->sql->insert($this->_table);
     $insert->values($data);
     $result = $this->_execute($insert);
     return $result->getGeneratedValue();
 }
开发者ID:biialaborg,项目名称:budocu.com,代码行数:7,代码来源:AbstractRepository.php

示例3: addNew

 /**
  * Adds a new record of the Room object in the database.
  * @param Room $room - a populated object to add.
  */
 public function addNew(Room $room)
 {
     $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $sql = new Sql($adapter);
     $insert = $sql->insert('room')->columns(array('number', 'name', 'building', 'attendant', 'posts'))->values(array('number' => $room->number, 'name' => $room->name, 'building' => $room->building, 'attendant' => $room->attendant, 'posts' => $room->posts));
     $sql->prepareStatementForSqlObject($insert)->execute();
 }
开发者ID:rav990,项目名称:AplikacjaRestPhp,代码行数:11,代码来源:Rooms.php

示例4: saveUser

 /**
  * Saves a user to a database
  *
  * @param array $user
  */
 public function saveUser(array $user)
 {
     $sql = new Sql($this->dbAdapter);
     $insert = $sql->insert('users');
     $insert->columns(array_keys($user))->values($user);
     $sql->prepareStatementForSqlObject($insert)->execute();
 }
开发者ID:dragonmantank,项目名称:phparch-zend-expressive,代码行数:12,代码来源:Users.php

示例5: create

 /**
  * @return bool $successfulCreate
  */
 protected function create() : bool
 {
     $insert = $this->sql->insert($this->getTablename());
     $id = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     $this->load($id);
     $success = true;
     return $success;
 }
开发者ID:geolysis,项目名称:gz3-base,代码行数:11,代码来源:AbstractManager.php

示例6: addRole

 public function addRole($serviceManager, $userRoleTable, $userIdField, $roleIdField, $userId, $roleId)
 {
     $adapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
     $sql = new Sql($adapter);
     $insert = $sql->insert()->into($userRoleTable)->columns(array($userIdField, $roleIdField))->values(array($userId, $roleId));
     $sqlString = $sql->getSqlStringForSqlObject($insert);
     $execute = $adapter->query($sqlString, $adapter::QUERY_MODE_EXECUTE);
     return $execute;
 }
开发者ID:fillup,项目名称:zfauthsaml,代码行数:9,代码来源:ZendDb.php

示例7: insert

 public function insert($data)
 {
     $adapter = $this->adapter;
     $sql = new Sql($this->adapter);
     $insert = $sql->insert('item_price');
     $insert->values($data);
     $selectString = $sql->getSqlStringForSqlObject($insert);
     return $results = $this->adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
 }
开发者ID:ankuradhey,项目名称:laundry,代码行数:9,代码来源:RateMapper.php

示例8: insert

 /**
  * 
  * @param string $tableName
  * @param array $data
  * @return bool
  */
 public function insert($tableName, array $data)
 {
     $sql = new Sql($this->adapter);
     $insert = $sql->insert($tableName);
     $insert->values($data);
     $sqlString = $sql->getSqlStringForSqlObject($insert);
     $results = $this->adapter->query($sqlString, Adapter::QUERY_MODE_EXECUTE);
     return $results;
 }
开发者ID:KIVagant,项目名称:console-tools,代码行数:15,代码来源:Fixture.php

示例9: insert

 /**
  * Insert
  *
  * @param  array $set
  * @return int
  */
 public function insert($set)
 {
     if (!$this->isInitialized) {
         $this->initialize();
     }
     $insert = $this->sql->insert();
     $insert->values($set);
     return $this->executeInsert($insert);
 }
开发者ID:artpoplsh,项目名称:learningZf2,代码行数:15,代码来源:AbstractTableGateway.php

示例10: insert

 /**
  * Insert
  * 
  * @param  array $set
  * @return int
  */
 public function insert($set)
 {
     $insert = $this->sql->insert();
     $insert->values($set);
     $statement = $this->sql->prepareStatementForSqlObject($insert);
     $result = $statement->execute();
     $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     return $result->getAffectedRows();
 }
开发者ID:rikaix,项目名称:zf2,代码行数:15,代码来源:TableGateway.php

示例11: createTransaction

 public function createTransaction($data)
 {
     $adapter = $this->adapter;
     $sql = new Sql($this->adapter);
     $insert = $sql->insert('user_transaction');
     $insert->values($data);
     $selectString = $sql->getSqlStringForSqlObject($insert);
     $results = $this->adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
     return array("trnx_id" => $results->getGeneratedValue());
 }
开发者ID:ankuradhey,项目名称:laundry,代码行数:10,代码来源:OrderMapper.php

示例12: create

 public function create(array $data)
 {
     $sql = new Sql($this->adapter);
     $this->adapter->getDriver()->getConnection()->beginTransaction();
     $insert = $sql->insert('places');
     $insert->values(['name' => $data['name'], 'latitude' => $data['latitude'], 'longitude' => $data['longitude']]);
     $query = $sql->getSqlStringForSqlObject($insert);
     /** @var Result $results */
     $results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
     $placeId = $results->getGeneratedValue();
     foreach ($data['types'] as $typeId) {
         $insert = $sql->insert('places_place_types');
         $insert->values(['place_id' => $placeId, 'place_type_id' => $typeId]);
         $q = $sql->getSqlStringForSqlObject($insert);
         $this->adapter->query($q, Adapter::QUERY_MODE_EXECUTE);
     }
     $this->adapter->getDriver()->getConnection()->commit();
     return $placeId;
 }
开发者ID:baptistecosta,项目名称:mon-partenaire,代码行数:19,代码来源:PlaceMapper.php

示例13: addNew

 /**
  * Adds a new record of the Equipment object in the database.
  * @param Equipment $equipment - a populated object to add.
  */
 public function addNew(Equipment $equipment)
 {
     if (!$this->is_init()) {
         throw new \Exception("Equipments collection uninitiated.");
     }
     $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $sql = new Sql($adapter);
     $insert = $sql->insert('equipment')->columns(array('cid', 'name', 'quantity', 'destiny', 'damaged', 'hire', 'adddate'))->values(array('cid' => $equipment->cid, 'name' => $equipment->name, 'quantity' => $equipment->quantity, 'destiny' => $equipment->destiny, 'damaged' => $equipment->damaged, 'hire' => $equipment->hire, 'adddate' => $equipment->adddate));
     $sql->prepareStatementForSqlObject($insert)->execute();
 }
开发者ID:rav990,项目名称:AplikacjaRestPhp,代码行数:14,代码来源:Equipments.php

示例14: create

 public function create($id)
 {
     $sql = new Sql($this->getAdapter());
     $insert = $sql->insert($this->getTableName());
     $insert->values(['id' => (string) $id]);
     $query = $sql->getSqlStringForSqlObject($insert);
     /** @var Result $results */
     $results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
     return $results->getGeneratedValue();
 }
开发者ID:baptistecosta,项目名称:mon-partenaire,代码行数:10,代码来源:ScrappedDepartmentMapper.php

示例15: saveHuntClubsHasPlayers

 public function saveHuntClubsHasPlayers($data)
 {
     $adapter = $this->tableGateway->getAdapter();
     $sql = new Sql($adapter);
     $insert = $sql->insert('hunt_clubs_has_players');
     $insert->values($data);
     $statement = $sql->prepareStatementForSqlObject($insert);
     $results = $statement->execute();
     $id = $adapter->getDriver()->getLastGeneratedValue();
     return $id;
 }
开发者ID:bladehr8,项目名称:bowhunter2015,代码行数:11,代码来源:HuntClubTable.php


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