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


PHP Connection::update方法代码示例

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


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

示例1: save

 /**
  * Saves the pool to the database.
  *
  * @param \MusicBox\Entity\Like $pool
  */
 public function save($pool)
 {
     $poolData = array('address_id' => $pool->getAddress()->getId(), 'access_info' => $pool->getAccessInfo());
     if ($pool->getId()) {
         $this->db->update('pools', $poolData, array('pool_id' => $pool->getId()));
         $newFile = $this->handleFileUpload($item);
         if ($newFile) {
             $poolData['image'] = $pool->getImage();
         }
     } else {
         // The pool is new, note the creation timestamp.
         $poolData['created_at'] = time();
         $this->db->insert('pools', $poolData);
         // Get the id of the newly created pool and set it on the entity.
         $id = $this->db->lastInsertId();
         $pool->setId($id);
         // If a new image was uploaded, update the pool with the new
         // filename.
         $newFile = $this->handleFileUpload($pool);
         if ($newFile) {
             $newData = array('image' => $pool->getImage());
             $this->db->update('pools', $newData, array('pool_id' => $id));
         }
     }
 }
开发者ID:stupae,项目名称:Akins-Parker-MikeO-Brien,代码行数:30,代码来源:PoolRepository.php

示例2: save

 /**
  * Saves the artist to the database.
  *
  * @param \MusicBox\Entity\Artist $artist
  */
 public function save($artist)
 {
     $artistData = array('name' => $artist->getName(), 'short_biography' => $artist->getShortBiography(), 'biography' => $artist->getBiography(), 'soundcloud_url' => $artist->getSoundCloudUrl(), 'image' => $artist->getImage());
     if ($artist->getId()) {
         // If a new image was uploaded, make sure the filename gets set.
         $newFile = $this->handleFileUpload($artist);
         if ($newFile) {
             $artistData['image'] = $artist->getImage();
         }
         $this->db->update('artists', $artistData, array('artist_id' => $artist->getId()));
     } else {
         // The artist is new, note the creation timestamp.
         $artistData['created_at'] = time();
         $this->db->insert('artists', $artistData);
         // Get the id of the newly created artist and set it on the entity.
         $id = $this->db->lastInsertId();
         $artist->setId($id);
         // If a new image was uploaded, update the artist with the new
         // filename.
         $newFile = $this->handleFileUpload($artist);
         if ($newFile) {
             $newData = array('image' => $artist->getImage());
             $this->db->update('artists', $newData, array('artist_id' => $id));
         }
     }
 }
开发者ID:juananruiz,项目名称:musicbox,代码行数:31,代码来源:ArtistRepository.php

示例3: update

 public function update($id, CacheRecord $cacheRecord)
 {
     $count = $this->db->update($this->entityTable, $cacheRecord->toArray(), array("id" => $id));
     if ($count <= 0) {
         throw new InvalidArgumentException("The update failed.");
     }
 }
开发者ID:konstantin-s,项目名称:silex-lazycache,代码行数:7,代码来源:CacheRecordSQLMapper.php

示例4: restorePortfolioTitle

 public function restorePortfolioTitle()
 {
     $totalPortfolioProcessed = 0;
     $nbPortfolioProcessed = 0;
     if ($this->connection->getSchemaManager()->tablesExist(array('icap__portfolio_widget_title'))) {
         $this->log('Restoring portfolio titles...');
         $rowPortfolioTitles = $this->connection->query('SELECT * FROM icap__portfolio_widget_title');
         $sql = 'SELECT aw.id, aw.user_id FROM icap__portfolio_abstract_widget aw WHERE id = :id';
         $stmt = $this->connection->prepare($sql);
         foreach ($rowPortfolioTitles as $rowPortfolioTitle) {
             $stmt->bindValue('id', $rowPortfolioTitle['id']);
             $stmt->execute();
             foreach ($stmt->fetchAll() as $rowAbstractWidget) {
                 $this->connection->update('icap__portfolio', ['title' => $rowPortfolioTitle['title'], 'slug' => $rowPortfolioTitle['slug']], ['id' => $rowAbstractWidget['user_id']]);
             }
             $this->connection->delete('icap__portfolio_abstract_widget', ['id' => $rowPortfolioTitle['id']]);
             ++$nbPortfolioProcessed;
             if ($nbPortfolioProcessed >= 10) {
                 $totalPortfolioProcessed += $nbPortfolioProcessed;
                 $nbPortfolioProcessed = 0;
                 $this->log('    processing portfolio...');
             }
         }
         $this->log(sprintf('  %d portfolio processed', $totalPortfolioProcessed + $nbPortfolioProcessed));
         $this->connection->delete('icap__portfolio_widget_type', ['name' => 'title']);
         $this->connection->getSchemaManager()->dropTable('icap__portfolio_widget_title');
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:28,代码来源:Updater050002.php

示例5: save

 /**
  * Saves the user to the database.
  *
  * @param \MusicBox\Entity\User $user
  */
 public function save($user)
 {
     $userData = array('username' => $user->getUsername(), 'mail' => $user->getMail(), 'role' => $user->getRole());
     // If the password was changed, re-encrypt it.
     if (strlen($user->getPassword()) != 88) {
         $userData['salt'] = uniqid(mt_rand());
         $userData['password'] = $this->encoder->encodePassword($user->getPassword(), $userData['salt']);
     }
     if ($user->getId()) {
         // If a new image was uploaded, make sure the filename gets set.
         $newFile = $this->handleFileUpload($user);
         if ($newFile) {
             $userData['image'] = $user->getImage();
         }
         $this->db->update('users', $userData, array('user_id' => $user->getId()));
     } else {
         // The user is new, note the creation timestamp.
         $userData['created_at'] = time();
         $this->db->insert('users', $userData);
         // Get the id of the newly created user and set it on the entity.
         $id = $this->db->lastInsertId();
         $user->setId($id);
         // If a new image was uploaded, update the user with the new
         // filename.
         $newFile = $this->handleFileUpload($user);
         if ($newFile) {
             $newData = array('image' => $user->getImage());
             $this->db->update('users', $newData, array('user_id' => $id));
         }
     }
 }
开发者ID:nix5longhorn,项目名称:musicbox,代码行数:36,代码来源:UserRepository.php

示例6: editLastLoginIp

 public function editLastLoginIp($admin)
 {
     $data = array();
     $lastLoginIp = $admin->getLastLoginIp();
     $data['lastLoginIp'] = $lastLoginIp;
     $result = $this->db->update('admin', $data, array('id' => $admin->getId()));
     return $result;
 }
开发者ID:yuyan2077,项目名称:ResourcesStore,代码行数:8,代码来源:AdminRepository.php

示例7: updateUsername

 private function updateUsername(ChangedUsername $payload)
 {
     $identifier = ['userIdentifier' => $payload->userIdentifier()->toString()];
     $data = [];
     $data['username'] = $payload->newUsername()->toString();
     $data['at'] = $payload->at()->format('Y-m-d H:i:s');
     $this->connection->update($this->table, $data, $identifier);
 }
开发者ID:wysow,项目名称:domain-application,代码行数:8,代码来源:UserListProjectorListener.php

示例8: save

 /**
  * {@inheritdoc}
  */
 public function save(Album $album)
 {
     $data = $album->getArrayCopy();
     if (null === $album->getId()) {
         return $this->db->insert('album', $data);
     } else {
         return $this->db->update('album', ['artist' => $data['artist'], 'title' => $data['title']], ['id' => $data['id']]);
     }
 }
开发者ID:wizard2014,项目名称:ze-album.dev,代码行数:12,代码来源:AlbumRepository.php

示例9: save

 /**
  * @param Album $album
  * @param int $id
  * @return int The number of affected rows
  */
 public function save(Album $album, $id = null)
 {
     $data = $album->getArrayCopy();
     if (null === $id) {
         return $this->db->insert('album', $data);
     } else {
         return $this->db->update('album', $data, ['id' => $id]);
     }
 }
开发者ID:twysto,项目名称:expressive-album,代码行数:14,代码来源:AlbumRepository.php

示例10: save

 /**
  * @param PublishedPost $publishedPost
  *
  * @return void
  */
 public function save(PublishedPost $publishedPost)
 {
     $data = ['title' => $publishedPost->title, 'content' => $publishedPost->content, 'category' => $publishedPost->category];
     try {
         $this->connection->insert('published_posts', array_merge($data, ['id' => $publishedPost->id]));
     } catch (\Doctrine\DBAL\DBALException $e) {
         $this->connection->update('published_posts', $data, ['id' => $publishedPost->id]);
     }
 }
开发者ID:msvrtan,项目名称:es-cqrs-broadway-workshop,代码行数:14,代码来源:DbalPublishedPostRepository.php

示例11: set

 /**
  * Sets an item in the store.
  *
  * @param string $key
  * @param mixed $value
  *
  * @return void
  */
 public function set($key, $value)
 {
     if ($this->exists($key)) {
         $this->db->update('configurations', ['value' => $value], ['code' => $key]);
         return;
     }
     // Insert it
     $this->db->insert('configurations', ['code' => $key, 'value' => $value]);
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:17,代码来源:DatabaseConfigStore.php

示例12: cacheSearchResult

 /**
  * @param string $location
  * @param array $data
  */
 public function cacheSearchResult($location, $data)
 {
     $qb = $this->db->createQueryBuilder()->select('*')->from('search_cache', 's')->where('s.location = :location')->setParameter('location', strtolower($location))->execute();
     if (count($qb->fetchAll()) === 0) {
         $this->db->insert('search_cache', ['location' => strtolower($location), 'cache' => serialize($data), 'time' => date('Y-m-d H:i:s')]);
         return;
     }
     $this->db->update('search_cache', ['cache' => serialize($data), 'time' => date('Y-m-d H:i:s')], ['location' => strtolower($location)]);
 }
开发者ID:praswicaksono,项目名称:tweet-world,代码行数:13,代码来源:SqliteStorage.php

示例13: update

 /**
  * Executes an SQL UPDATE statement on a table.
  *
  * @param array $data An associative array containing column-value pairs.
  * @param array $identifier The update criteria. An associative array containing column-value pairs.
  * @return integer The number of affected rows.
  */
 public function update(array $data, array $identifier)
 {
     if (array_key_exists($this->createdAtRowName, $data)) {
         unset($data[$this->createdAtRowName]);
     }
     if (!array_key_exists($this->updatedAtRowName, $data)) {
         $data[$this->updatedAtRowName] = $this->now->format($this->dateFormat);
     }
     return $this->conn->update($this->getTableName(), $data, $identifier);
 }
开发者ID:10mado,项目名称:silexcane,代码行数:17,代码来源:DbTable.php

示例14: save

 /**
  * Saves the restaurant to the database.
  *
  * @param Restaurant $restaurant
  *
  * @return Restaurant $restaurant
  */
 public function save($restaurant)
 {
     $restaurantData = array('nom' => $restaurant->getNom(), 'adresse' => $restaurant->getAdresse(), 'cp' => $restaurant->getCp(), 'ville' => $restaurant->getVille(), 'ouverture' => $restaurant->getOuverture(), 'fermeture' => $restaurant->getFermeture(), 'likes' => $restaurant->getLikes());
     if ($restaurant->getId()) {
         $this->db->update('restaurants', $restaurantData, array('id' => $restaurant->getId()));
     } else {
         $this->db->insert('restaurants', $restaurantData);
         $last = $this->db->lastInsertId();
         return $this->find($last);
     }
 }
开发者ID:KristenGarnier,项目名称:CommandeRestau,代码行数:18,代码来源:RestaurantRepository.php

示例15: save

 /**
  * Saves the produit to the database.
  *
  * @param Produit $produit
  *
  * @return Produit $produit
  */
 public function save($produit)
 {
     $produitData = array('nom' => $produit->getNom(), 'prix' => $produit->getPrix(), 'type' => $produit->getType(), 'image' => $produit->getImage(), 'restaurant' => $produit->getRestaurant());
     if ($produit->getId()) {
         $this->db->update('produits', $produitData, array('id' => $produit->getId()));
     } else {
         $this->db->insert('produits', $produitData);
         $last = $this->db->lastInsertId();
         return $this->find($last);
     }
 }
开发者ID:KristenGarnier,项目名称:CommandeRestau,代码行数:18,代码来源:ProduitRepository.php


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