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


PHP Connection::prepare方法代码示例

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


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

示例1: it_saves_and_reads

 /**
  * @test
  */
 public function it_saves_and_reads()
 {
     $schema = new Schema();
     SnapshotStoreSchema::create($schema, 'foo_snapshot');
     foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
         $this->connection->executeQuery($sql);
     }
     $adapter = new DoctrineSnapshotAdapter($this->connection);
     $aggregateType = AggregateType::fromString('foo');
     $aggregateRoot = new \stdClass();
     $aggregateRoot->foo = 'bar';
     $time = microtime(true);
     if (false === strpos($time, '.')) {
         $time .= '.0000';
     }
     $now = \DateTimeImmutable::createFromFormat('U.u', $time);
     $snapshot = new Snapshot($aggregateType, 'id', $aggregateRoot, 1, $now);
     $adapter->save($snapshot);
     $snapshot = new Snapshot($aggregateType, 'id', $aggregateRoot, 2, $now);
     $adapter->save($snapshot);
     $this->assertNull($adapter->get($aggregateType, 'invalid'));
     $readSnapshot = $adapter->get($aggregateType, 'id');
     $this->assertEquals($snapshot, $readSnapshot);
     $statement = $this->connection->prepare('SELECT * FROM foo_snapshot');
     $statement->execute();
     $snapshots = $statement->fetchAll();
     $this->assertCount(1, $snapshots);
 }
开发者ID:sandrokeil,项目名称:snapshot-doctrine-adapter,代码行数:31,代码来源:DoctrineSnapshotAdapterTest.php

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

示例3: applyChanges

 private function applyChanges($areas, $rules, $reverseRules)
 {
     $stmt = $this->conn->prepare('UPDATE `' . CoreTables::AREA_TBL . '` SET `statusId` = :statusId, `lastUpdatedAt` = :lastUpdated WHERE `id` = :id');
     $count = 0;
     foreach ($areas as $area) {
         foreach ($rules as $rule) {
             if ($this->isMatching($area, $rule)) {
                 $stmt->bindValue(':id', $area['id']);
                 $stmt->bindValue(':statusId', $rule['newStatusId']);
                 $stmt->bindValue(':lastUpdated', time());
                 $stmt->execute();
                 $count++;
                 continue 2;
             }
         }
         foreach ($reverseRules as $rule) {
             if ($this->isNotMatching($area, $rule)) {
                 $stmt->bindValue(':id', $area['id']);
                 $stmt->bindValue(':statusId', $rule['prevStatusId']);
                 $stmt->bindValue(':lastUpdated', time());
                 $stmt->execute();
                 $count++;
                 continue 2;
             }
         }
     }
     return $count;
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:28,代码来源:UpdateRepository.php

示例4: findUserOfTodo

 /**
  * @param $todoId
  * @return null|\stdClass containing userData
  */
 public function findUserOfTodo($todoId)
 {
     $stmt = $this->connection->prepare(sprintf("SELECT u.* FROM %s as u JOIN %s as t ON u.id = t.assignee_id  where t.id = :todo_id", Table::USER, Table::TODO));
     $stmt->bindValue('todo_id', $todoId);
     $stmt->execute();
     return $stmt->fetch();
 }
开发者ID:sandrokeil,项目名称:proophessor-do,代码行数:11,代码来源:UserFinder.php

示例5: writeBacklog

 /**
  * @param Backlog[] $backlogs
  */
 private function writeBacklog(array $backlogs)
 {
     $statement = $this->connection->prepare("\n            INSERT IGNORE INTO s_es_backlog (`event`, `payload`, `time`)\n            VALUES (:event, :payload, :time);\n        ");
     foreach ($backlogs as $backlog) {
         $statement->execute([':event' => $backlog->getEvent(), ':payload' => json_encode($backlog->getPayload()), ':time' => $backlog->getTime()->format('Y-m-d H:i:s')]);
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:10,代码来源:BacklogProcessor.php

示例6: buildOptions

 protected function buildOptions(ReportParameter $parameter)
 {
     $options = array();
     if ($parameter->getType() == ReportParameter::TYPE_QUERY) {
         $stmt = $this->connection->prepare($parameter->getChoices());
         $stmt->execute();
         $results = $stmt->fetchAll();
         $values = array(null => '');
         $keySet = array_keys(current($results));
         $key = current(array_slice($keySet, 0, 1));
         $value = current(array_slice($keySet, 1, 1));
         foreach ($results as $result) {
             $values[$result[$value]] = $result[$key];
         }
         $options = array_merge($options, array('choices' => $values));
         $parameter->setType(ChoiceType::class);
     }
     $normalizer = new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer();
     $normalizer->setIgnoredAttributes(array('id', 'name', 'type', 'created', 'modified', 'active'));
     $serializer = new \Symfony\Component\Serializer\Serializer(array($normalizer));
     $options = array_merge($serializer->normalize($parameter), $options);
     foreach ($options as $key => $value) {
         if (is_null($value)) {
             unset($options[$key]);
         }
     }
     $this->handleConstraints($options);
     return $options;
 }
开发者ID:stanlemon,项目名称:report-bundle,代码行数:29,代码来源:ReportParameterConverter.php

示例7: findById

 /**
  * @param $userId
  * @return null|\stdClass containing userData
  */
 public function findById($userId)
 {
     $stmt = $this->connection->prepare(sprintf("SELECT * FROM %s where id = :user_id", Table::USER));
     $stmt->bindValue('user_id', $userId);
     $stmt->execute();
     return $stmt->fetch();
 }
开发者ID:renereed1,项目名称:proophessor-do,代码行数:11,代码来源:UserFinder.php

示例8: findById

 /**
  * @param string $todoId
  * @return \stdClass of todoData
  */
 public function findById($todoId)
 {
     $stmt = $this->connection->prepare(sprintf("SELECT * FROM %s where id = :todo_id", Table::TODO));
     $stmt->bindValue('todo_id', $todoId);
     $stmt->execute();
     return $stmt->fetch();
 }
开发者ID:renereed1,项目名称:proophessor-do,代码行数:11,代码来源:TodoFinder.php

示例9: execute

 /**
  * Execute
  */
 public function execute(array $criteria = null)
 {
     $stmt = $this->connection->prepare($this->buildQuery());
     $stmt->execute(array('mds' => $criteria['start_date']->format('m/d/Y'), 'mde' => $criteria['end_date']->format('m/d/Y')));
     $results = $stmt->fetchAll();
     $stmt->closeCursor();
     return $results;
 }
开发者ID:upenn-dag,项目名称:patient-repository,代码行数:11,代码来源:PDSDiagnosisSource.php

示例10: getStreamIds

 /**
  * {@inheritDoc}
  */
 public function getStreamIds()
 {
     $statement = $this->connection->prepare('SELECT DISTINCT uuid FROM ' . config('broadway.event-store.table'));
     $statement->execute();
     return array_map(function ($row) {
         return $row['uuid'];
     }, $statement->fetchAll());
 }
开发者ID:josecelano,项目名称:Laravel-Broadway-Demo,代码行数:11,代码来源:MysqlEventStorePartRepository.php

示例11: findAll

 /**
  * @return ReadModelInterface[]
  */
 public function findAll()
 {
     $statement = $this->connection->prepare(sprintf('SELECT serialized FROM %s WHERE class = :class', static::TABLE));
     $statement->execute(['class' => $this->class]);
     return array_map(function ($row) {
         return $this->serializer->deserialize(json_decode($row['serialized'], true));
     }, $statement->fetchAll(\PDO::FETCH_ASSOC));
 }
开发者ID:msvrtan,项目名称:es-cqrs-broadway-workshop,代码行数:11,代码来源:PoorlyDesignedBroadwayDbalRepository.php

示例12: execute

 /**
  * Execute
  */
 public function execute(array $criteria = null)
 {
     $stmt = $this->connection->prepare($this->buildQuery());
     $stmt->execute(array('first_id' => $criteria['first_id'], 'last_id' => $criteria['last_id']));
     $results = $stmt->fetchAll();
     $stmt->closeCursor();
     return $results;
 }
开发者ID:upenn-dag,项目名称:patient-repository,代码行数:11,代码来源:HMTBSource.php

示例13: __construct

 public function __construct(Connection $con)
 {
     $this->con = $con;
     $this->platform = $con->getDatabasePlatform();
     $this->phpType = Type::getType(PhpTypeType::NAME);
     $this->fStmt = $con->prepare(self::INSERT_FUNC_SQL);
     $this->mStmt = $con->prepare(self::INSERT_METHOD_SQL);
 }
开发者ID:walkeralencar,项目名称:ci-php-analyzer,代码行数:8,代码来源:ParameterPersister.php

示例14: getCategoryPaintings

 public function getCategoryPaintings($catId)
 {
     $sql = 'SELECT * FROM pinturas where categorias_pintura_id = :catId';
     $stmt = $this->db->prepare($sql);
     $stmt->bindValue('catId', $catId);
     $stmt->execute();
     return $stmt->fetchAll();
 }
开发者ID:ricardclau,项目名称:SylviaEstruch-Silex,代码行数:8,代码来源:PinturaService.php

示例15: getCategoryPerformances

 public function getCategoryPerformances($catId)
 {
     $sql = 'SELECT * FROM teatros where categorias_teatro_id = :catId';
     $stmt = $this->db->prepare($sql);
     $stmt->bindValue('catId', $catId);
     $stmt->execute();
     return $stmt->fetchAll();
 }
开发者ID:ricardclau,项目名称:SylviaEstruch-Silex,代码行数:8,代码来源:TeatroService.php


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