當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。