當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TableGateway::update方法代碼示例

本文整理匯總了PHP中Zend\Db\TableGateway\TableGateway::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP TableGateway::update方法的具體用法?PHP TableGateway::update怎麽用?PHP TableGateway::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Db\TableGateway\TableGateway的用法示例。


在下文中一共展示了TableGateway::update方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doUpdateModel

 /**
  * {@inheritDoc}
  */
 protected function doUpdateModel($model)
 {
     if ($id = $this->getModelId($model)) {
         $this->tableGateway->update($this->tableGateway->getResultSetPrototype()->getHydrator()->extract($model), array("{$this->idField} = ?" => $id));
     } else {
         $this->tableGateway->insert($this->tableGateway->getResultSetPrototype()->getHydrator()->extract($model));
     }
 }
開發者ID:stan5621,項目名稱:eduwind,代碼行數:11,代碼來源:TableGatewayStorage.php

示例2: update

 public function update($id, array $data)
 {
     $this->table->update($data, array($this->identifierName => $id));
     $entity = $this->find($id);
     if (!$entity) {
         throw new \Exception("Entity not updated?");
     }
     return $entity;
 }
開發者ID:kapitchi,項目名稱:kap-apigility,代碼行數:9,代碼來源:DbEntityRepository.php

示例3: persist

 /**
  * @param AbstractEntity $entity
  * @return $this
  */
 public function persist(AbstractEntity $entity)
 {
     $data = $this->hydrator->extract($entity);
     if ($this->hasIdentity($entity)) {
         $this->gateway->update($data, ['id' => $entity->getId()]);
     } else {
         $this->gateway->insert($data);
         $entity->setId($this->gateway->getLastInsertValue());
     }
     return $this;
 }
開發者ID:nathanphan,項目名稱:cleanphp-example,代碼行數:15,代碼來源:AbstractDataTable.php

示例4: internalSave

 /**
  * @param AbstractModel $model
  */
 protected function internalSave(AbstractModel $model)
 {
     $pKey = $this->getPrimaryKey();
     if (isset($model->id)) {
         $this->tableGateway->update($model->toArray(), [$pKey => $model->{$pKey}]);
     } else {
         $this->tableGateway->insert($model->toArray());
         $id = $this->tableGateway->getLastInsertValue();
         $model->{$pKey} = $id;
     }
 }
開發者ID:jeremygiberson,項目名稱:what-changed,代碼行數:14,代碼來源:AbstractMapper.php

示例5: saveCategory

 public function saveCategory(Category $category)
 {
     $data = array('id_category' => $category->id_category, 'name' => $category->name, 'slug' => $category->slug);
     $id = (int) $category->id_category;
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } elseif ($this->getCategoryById($id)) {
         $this->tableGateway->update($data, array('id_category = ?' => $id));
     } else {
         throw new \Exception('Form id does not exist');
     }
 }
開發者ID:Lebe1ge,項目名稱:JobeetForZF2,代碼行數:12,代碼來源:CategoryTable.php

示例6: saveWarlog

 /**
  * Saves an account to the db. If the id exists the given dataset will be updated
  * @param \Account\Model\Account $account
  *
  * @throws \Exception
  */
 public function saveWarlog(Warlog $warlog)
 {
     $data = ['wins' => $warlog->getWins(), 'losses' => $warlog->getLosses(), 'draws' => $warlog->getDraws()];
     if (!$warlog->getId()) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getWarlog()) {
             $this->tableGateway->update($data, ['id' => $warlog->getId()]);
         } else {
             throw new \Exception('Account id does not exist');
         }
     }
 }
開發者ID:snowiow,項目名稱:eternaldeztiny,代碼行數:19,代碼來源:WarlogTable.php

示例7: saveForm

 public function saveForm(Form $form)
 {
     $data = array('name' => $form->name);
     $id = (int) $form->id;
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getForm($id)) {
             $this->tableGateway->update($data, array('id' => $id));
         } else {
             throw new \Exception('Form id does not exist');
         }
     }
 }
開發者ID:elmosgot,項目名稱:cool-builder,代碼行數:14,代碼來源:FormTable.php

示例8: saveNewsCategory

 /**
  * Saves the given NewsCategory object to the db
  *
  *  @param NewsCategory
  *  @throws \Exception
  */
 public function saveNewsCategory(NewsCategory $nc)
 {
     $data = ['name' => $nc->getName()];
     $id = (int) $nc->getId();
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getNewsCategoryBy(['id' => $id])) {
             $this->tableGateway->update($data, ['id' => $id]);
         } else {
             throw new \Ȩxception('NewsCategory id does not exist');
         }
     }
 }
開發者ID:snowiow,項目名稱:eternaldeztiny,代碼行數:20,代碼來源:NewsCategoryTable.php

示例9: saveWarstatus

 /**
  * Saves the given object ot the db
  * @param Warstatus $warstatus
  * @throws \Exception
  */
 public function saveWarstatus(Warstatus $warstatus)
 {
     $data = $warstatus->getArrayCopy();
     if ($warstatus->getId() == 0) {
         throw new \Exception('Id needed to save a warstatus');
     } else {
         if ($this->getWarstatus((int) $warstatus->getId())) {
             $this->tableGateway->update($data, ['id' => (int) $warstatus->getId()]);
         } else {
             $data['id'] = $warstatus->getId();
             $this->tableGateway->insert($data);
         }
     }
 }
開發者ID:snowiow,項目名稱:eternaldeztiny,代碼行數:19,代碼來源:WarstatusTable.php

示例10: saveMedia

 /**
  * Saves the given media object to the db
  *
  * @param \Media\Model\Media $media
  *
  * @throws \Exception
  */
 public function saveMedia(Media $media)
 {
     $data = ['account_id' => $media->getAccountId(), 'title' => $media->getTitle(), 'url' => $media->getUrl(), 'date_posted' => $media->getDatePosted()];
     $id = (int) $media->getId();
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getMedia($id)) {
             $this->tableGateway->update($data, ['id' => $id]);
         } else {
             throw new \Exception('Media id does not exist');
         }
     }
 }
開發者ID:snowiow,項目名稱:eternaldeztiny,代碼行數:21,代碼來源:MediaTable.php

示例11: saveCore

 public function saveCore(Core $core)
 {
     $data = array('name' => $core->name);
     $id = (int) $core->id;
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getCore($id)) {
             $data['last_updated'] = $core->lastUpdated;
             $this->tableGateway->update($data, array('id' => $id));
         } else {
             throw new \Exception('Core id does not exist');
         }
     }
 }
開發者ID:elmosgot,項目名稱:cool-builder,代碼行數:15,代碼來源:CoreTable.php

示例12: _update

 protected function _update($itemData, $createIfAbsent = false)
 {
     $adapter = $this->dbTable->getAdapter();
     $identifier = $this->getIdentifier();
     if (!isset($itemData[$identifier])) {
         throw new DataStoreException('Item must has primary key');
     }
     $id = $itemData[$identifier];
     $this->checkIdentifierType($id);
     $queryStr = 'SELECT ' . Select::SQL_STAR . ' FROM ' . $adapter->platform->quoteIdentifier($this->dbTable->getTable()) . ' WHERE ' . $adapter->platform->quoteIdentifier($identifier) . ' = ?' . ' FOR UPDATE';
     //is row with this index exist?
     $rowset = $adapter->query($queryStr, array($id));
     $isExist = !is_null($rowset->current());
     $result = [];
     switch (true) {
         case !$isExist && !$createIfAbsent:
             throw new DataStoreException('Can\'t update item with "id" = ' . $id);
         case !$isExist && $createIfAbsent:
             $this->dbTable->insert($itemData);
             $result = $itemData;
             break;
         case $isExist:
             unset($itemData[$identifier]);
             $this->dbTable->update($itemData, array($identifier => $id));
             $rowset = $adapter->query($queryStr, array($id));
             $result = $rowset->current()->getArrayCopy();
             break;
     }
     return $result;
 }
開發者ID:avz-cmf,項目名稱:zaboy-rest,代碼行數:30,代碼來源:DbTable.php

示例13: update

 public function update($set, $where)
 {
     if (!$where) {
         return [];
     }
     return $this->tableGateway->update($set, $where);
 }
開發者ID:sedpro,項目名稱:test_skyeng,代碼行數:7,代碼來源:Simple.php

示例14: updateSales

 public function updateSales($data = null)
 {
     $id = $data['id'];
     $data['sales_markup'] = preg_replace("|[\\s]+|s", " ", $data['sales_markup']);
     $data['sales_active'] = $data['sales_active'] == 'on' ? '1' : '0';
     parent::update($data, array('id' => $id));
 }
開發者ID:vikitina,項目名稱:ekalan,代碼行數:7,代碼來源:Sales.php

示例15: updateanywhere

 public function updateanywhere($mytable, array $data, $where)
 {
     $db = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $table = new TableGateway($mytable, $db);
     $results = $table->update($data, $where);
     return 1;
 }
開發者ID:arvindjha304,項目名稱:discoveryCRM,代碼行數:7,代碼來源:Index.php


注:本文中的Zend\Db\TableGateway\TableGateway::update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。