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


PHP Connection::insert方法代码示例

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


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

示例1: insertTableRows

 /**
  * @param string $tableName
  * @param array $rows
  */
 protected function insertTableRows($tableName, array $rows)
 {
     foreach ($rows as $rowKey => $values) {
         $this->connection->insert($tableName, $this->parser->parse($values));
         $this->parser->addReference($rowKey, $this->connection->lastInsertId());
     }
 }
开发者ID:comphppuebla,项目名称:dbal-fixtures,代码行数:11,代码来源:ConnectionPersister.php

示例2: save

 public function save(Order $order)
 {
     $data = $order->jsonSerialize();
     unset($data['id']);
     $this->connection->insert($this->getTableName(), $data);
     $order->setId($this->connection->lastInsertId());
 }
开发者ID:Basster,项目名称:hs-bremen-web-api,代码行数:7,代码来源:OrderRepository.php

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

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

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

 /**
  * @param ReminderWasAddedToTodo $event
  * @return void
  */
 public function onReminderWasAddedToTodo(ReminderWasAddedToTodo $event)
 {
     // remove other reminder for todo first
     $this->connection->delete(Table::TODO_REMINDER, ['todo_id' => $event->todoId()->toString()]);
     $reminder = $event->reminder();
     $this->connection->insert(Table::TODO_REMINDER, ['todo_id' => $event->todoId()->toString(), 'reminder' => $reminder->toString(), 'status' => $reminder->status()->toString()]);
 }
开发者ID:mikemix,项目名称:proophessor-do,代码行数:11,代码来源:TodoReminderProjector.php

示例7: executeUpgrade

 public function executeUpgrade(Connection $connection)
 {
     // update action class names
     $actions = ['Fusio\\Action\\BeanstalkPush' => 'Fusio\\Impl\\Action\\MqBeanstalk', 'Fusio\\Action\\CacheResponse' => 'Fusio\\Impl\\Action\\CacheResponse', 'Fusio\\Action\\Composite' => 'Fusio\\Impl\\Action\\Composite', 'Fusio\\Action\\Condition' => 'Fusio\\Impl\\Action\\Condition', 'Fusio\\Action\\HttpRequest' => 'Fusio\\Impl\\Action\\HttpRequest', 'Fusio\\Action\\Pipe' => 'Fusio\\Action\\Pipe', 'Fusio\\Action\\RabbitMqPush' => 'Fusio\\Impl\\Action\\MqAmqp', 'Fusio\\Action\\SqlExecute' => 'Fusio\\Impl\\Action\\SqlExecute', 'Fusio\\Action\\SqlFetchAll' => 'Fusio\\Impl\\Action\\SqlFetchAll', 'Fusio\\Action\\SqlFetchRow' => 'Fusio\\Impl\\Action\\SqlFetchRow', 'Fusio\\Action\\StaticResponse' => 'Fusio\\Impl\\Action\\StaticResponse'];
     foreach ($actions as $oldClass => $newClass) {
         $connection->executeUpdate('UPDATE fusio_action SET class = :new_class WHERE class = :old_class', ['new_class' => $newClass, 'old_class' => $oldClass]);
     }
     // update connection class names
     $actions = ['Fusio\\Connection\\Beanstalk' => 'Fusio\\Impl\\Connection\\Beanstalk', 'Fusio\\Connection\\DBAL' => 'Fusio\\Impl\\Connection\\DBAL', 'Fusio\\Connection\\DBALAdvanced' => 'Fusio\\Impl\\Connection\\DBALAdvanced', 'Fusio\\Connection\\MongoDB' => 'Fusio\\Impl\\Connection\\MongoDB', 'Fusio\\Connection\\Native' => 'Fusio\\Impl\\Connection\\Native', 'Fusio\\Connection\\RabbitMQ' => 'Fusio\\Impl\\Connection\\RabbitMQ'];
     foreach ($actions as $oldClass => $newClass) {
         $connection->executeUpdate('UPDATE fusio_connection SET class = :new_class WHERE class = :old_class', ['new_class' => $newClass, 'old_class' => $oldClass]);
     }
     // update routes class names
     $routes = $connection->fetchAll('SELECT id, controller FROM fusio_routes');
     foreach ($routes as $route) {
         if (substr($route['controller'], 0, 6) == 'Fusio\\' && substr($route['controller'], 0, 11) != 'Fusio\\Impl\\') {
             $newController = 'Fusio\\Impl\\' . substr($route['controller'], 6);
             $connection->executeUpdate('UPDATE fusio_routes SET controller = :controller WHERE id = :id', ['controller' => $newController, 'id' => $route['id']]);
         }
     }
     // insert new classes table
     $data = $this->getInstallInserts();
     if (isset($data['fusio_connection_class'])) {
         foreach ($data['fusio_connection_class'] as $row) {
             $connection->insert('fusio_connection_class', $row);
         }
     }
     if (isset($data['fusio_action_class'])) {
         foreach ($data['fusio_action_class'] as $row) {
             $connection->insert('fusio_action_class', $row);
         }
     }
 }
开发者ID:uqiauto,项目名称:fusio,代码行数:33,代码来源:Version017.php

示例8: collect

 /**
  * @return JsonResponse
  */
 public function collect()
 {
     $toSave = array();
     $count = 0;
     $currentPageIndex = 0;
     while ($count < self::NB_POSTS) {
         $url = self::getUrl($currentPageIndex++);
         try {
             $html = $this->curlUtils->getResource($url);
             $posts = $this->postParserUtils->getPosts($html);
             foreach ($posts as $post) {
                 if ($count === self::NB_POSTS) {
                     break;
                 }
                 $postContent = $this->postParserUtils->parse($post);
                 $toSave[$count++] = $postContent;
             }
         } catch (\Exception $exception) {
             return new JsonResponse($exception);
         }
     }
     for ($i = 0; $i < count($toSave); $i++) {
         $this->dbal->insert(self::MODEL, $toSave[$i]);
     }
     $toReturn = count($toSave) . " posts have been added";
     return new JsonResponse($toReturn);
 }
开发者ID:scottie34,项目名称:silex-fwk,代码行数:30,代码来源:PostController.php

示例9: save

 public function save($user)
 {
     $userData = array('name' => $user->getName(), 'email' => $user->getEmail(), 'password' => $user->getPassword(), 'joinTime' => $user->getJoinTime(), 'registerIp' => $user->getRegisterIp(), 'sharedKey' => $user->getSharedKey(), 'integration' => $user->getIntegration(), 'shareKey' => $user->getShareKey());
     $this->db->insert('user', $userData);
     $id = $this->db->lastInsertId();
     $user->setId($id);
 }
开发者ID:yuyan2077,项目名称:ResourcesStore,代码行数:7,代码来源:UserRepository.php

示例10: create

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

示例11: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     $record = $record['formatted'];
     try {
         $this->connection->insert($this->tableName, $record);
     } catch (\Exception $e) {
     }
 }
开发者ID:BlueTM,项目名称:LexikMonologBrowserBundle,代码行数:11,代码来源:DoctrineDBALHandler.php

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

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

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

示例15: insertRegisteredUser

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


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