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


PHP DBAL\Connection类代码示例

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


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

示例1: findStudentAttendances

 /**
  * Busca as faltas dos tipos $type de todos os alunos atualmente matriculados na turma $schoolClass na data $date.
  * 
  * @param Connection $conn
  * @param integer $schoolClass
  * @param string $date
  * @param integer $type
  * @return array
  */
 public static function findStudentAttendances(Connection $conn, $schoolClass, $date, $type)
 {
     $query = $conn->createQueryBuilder();
     $sth = $query->select('a.enrollment_id')->from('attendance', 'a')->join('a', 'enrollment', 'e', 'e.enrollment_id = a.enrollment_id')->where('e.enrollment_enddate IS NULL')->andWhere('e.class_id = ?')->andWhere('a.attendance_date = ?')->andWhere('a.attendance_type_id = ?')->setParameters([$schoolClass, $date, $type])->execute();
     $list = $sth->fetchAll();
     return $list;
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:16,代码来源:AttendanceRepository.php

示例2: singleImport

 private function singleImport($config, OutputInterface &$output, $entity_key = null)
 {
     $this->connection = $this->connectionFactory->createConnection($config['database']);
     $this->connection->getConfiguration()->getSQLLogger(null);
     if ($entity_key) {
         if (!isset($config['maps'][$entity_key])) {
             throw new \Exception("Entity alias not found: " . $entity_key);
         }
         $map = $config['maps'][$entity_key];
         if (!$this->container->has($map['old_data']['service_id'])) {
             throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
         }
         $result = $this->importEntity($map);
         $output->writeln("<info>Total " . count($result) . " {$entity_key} imported </info>");
     } else {
         foreach ((array) $config['maps'] as $key => $map) {
             if (!$this->container->has($map['old_data']['service_id'])) {
                 throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
             }
             $offset = 0;
             do {
                 $result = $this->importEntity($map);
                 $output->writeln("<info>Total " . count($result) . " {$key} imported </info>");
                 if (!$result) {
                     break;
                 }
                 $offset++;
                 $this->setOffset($offset);
             } while (true);
         }
     }
     $this->connection->close();
 }
开发者ID:hmert,项目名称:importbundle,代码行数:33,代码来源:ImportManager.php

示例3: checkStandardConnection

 /**
  * @param Connection $connection
  * @return Success|Failure
  */
 private function checkStandardConnection(Connection $connection)
 {
     if ($connection->ping()) {
         return new Success(get_class($connection));
     }
     return new Failure(get_class($connection));
 }
开发者ID:abacaphiliac,项目名称:doctrine-orm-diagnostics-module,代码行数:11,代码来源:CheckConnection.php

示例4: __construct

 /**
  * Construtor
  *
  * @param Connection $connection
  * @param array $rootAliases
  * @param array $fieldMap
  */
 public function __construct(Connection $connection, array $rootAliases, array $fieldMap = array())
 {
     $this->rootAliases = $rootAliases;
     $this->fieldMap = $fieldMap;
     $this->conn = $connection;
     $this->expr = $this->conn->getExpressionBuilder();
 }
开发者ID:brodaproject,项目名称:broda,代码行数:14,代码来源:DbalQueryExpressionVisitor.php

示例5: stopQuery

 public function stopQuery()
 {
     if ($this->explainRunning) {
         return;
     }
     $keys = array_keys($this->queries);
     $key = end($keys);
     $this->queries[$key][self::TIME] = Debugger::timer('doctrine');
     $this->totalTime += $this->queries[$key][self::TIME];
     // get EXPLAIN for SELECT queries
     if ($this->doExplains) {
         if ($this->connection === NULL) {
             throw new \Nette\InvalidStateException('You must set a Doctrine\\DBAL\\Connection to get EXPLAIN.');
         }
         $query = $this->queries[$key][self::SQL];
         if (strtoupper(substr(ltrim($query), 0, 6)) !== 'SELECT') {
             // only SELECTs are supported
             return;
         }
         // prevent logging explains & infinite recursion
         $this->explainRunning = TRUE;
         $params = $this->queries[$key][self::PARAMS];
         $types = $this->queries[$key][self::TYPES];
         $stmt = $this->connection->executeQuery('EXPLAIN ' . $query, $params, $types);
         $this->queries[$key][self::EXPLAIN] = $stmt->fetchAll();
         $this->explainRunning = FALSE;
     }
 }
开发者ID:janmarek,项目名称:doctrine,代码行数:28,代码来源:ConnectionPanel.php

示例6: setUp

 /**
  * Initializes the database (once).
  *
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 protected function setUp()
 {
     if (null === static::$_conn) {
         $dbPath = __DIR__ . '/../../../db.sqlite';
         if (file_exists($dbPath)) {
             unlink($dbPath);
         }
         $params = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
         static::$_conn = DriverManager::getConnection($params);
         static::$_conn->getConfiguration()->setSQLLogger(null);
     }
     if (null === static::$_em) {
         $paths = [__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/ORM/Resources/mapping'];
         $isDevMode = true;
         $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
         $em = EntityManager::create(static::$_conn, $config);
         $classes = [];
         foreach (static::$_classes as $class) {
             array_push($classes, $em->getClassMetadata($class));
         }
         $schemaTool = new SchemaTool($em);
         $schemaTool->dropSchema($classes);
         $schemaTool->createSchema($classes);
         // Load fixtures
         $loader = new Loader();
         $loader->loadFromDirectory(__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/Fixtures');
         $purger = new ORMPurger();
         $executor = new ORMExecutor($em, $purger);
         $executor->execute($loader->getFixtures());
         static::$_em = $em;
     }
 }
开发者ID:ekyna,项目名称:commerce,代码行数:39,代码来源:DatabaseTestCase.php

示例7: migrateBadgeTables

 /**
  * @param Connection $connection
  * @param AppKernel  $kernel
  *
  * @throws \Claroline\MigrationBundle\Migrator\InvalidDirectionException
  * @throws \Claroline\MigrationBundle\Migrator\InvalidVersionException
  * @throws \Doctrine\DBAL\Migrations\MigrationException
  */
 protected function migrateBadgeTables(Connection $connection, AppKernel $kernel)
 {
     $portfolioBundle = $this->container->get('claroline.persistence.object_manager')->getRepository('ClarolineCoreBundle:Plugin')->findBy(array('vendorName' => 'Icap', 'bundleName' => 'PortfolioBundle'));
     $portfolioBundle = count($portfolioBundle) === 1 ? true : false;
     if (!$portfolioBundle && $connection->getSchemaManager()->tablesExist(['icap__portfolio_widget_badges'])) {
         $this->log('Deleting portfolios badges tables...');
         $connection->getSchemaManager()->dropTable('icap__portfolio_widget_badges_badge');
         $connection->getSchemaManager()->dropTable('icap__portfolio_widget_badges');
         $this->log('Portfolios badges tables deleted.');
     }
     if ($portfolioBundle && !$connection->getSchemaManager()->tablesExist(['icap__portfolio_widget_badges'])) {
         $badgeBundle = $kernel->getBundle('IcapBadgeBundle');
         $this->log('Executing migrations for portfolio interaction');
         $migrationsDir = "{$badgeBundle->getPath()}/Installation/Migrations";
         $migrationsName = "{$badgeBundle->getName()} migration";
         $migrationsNamespace = "{$badgeBundle->getNamespace()}\\Installation\\Migrations";
         $migrationsTableName = 'doctrine_' . strtolower($badgeBundle->getName()) . '_versions';
         $config = new Configuration($connection);
         $config->setName($migrationsName);
         $config->setMigrationsDirectory($migrationsDir);
         $config->setMigrationsNamespace($migrationsNamespace);
         $config->setMigrationsTableName($migrationsTableName);
         $config->registerMigrationsFromDirectory($migrationsDir);
         $migration = new Migration($config);
         $executedQueriesNumber = $migration->migrate('20150929141509');
         $this->log(sprintf('%d queries executed', $executedQueriesNumber));
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:36,代码来源:Updater060300.php

示例8: let

 function let(EntityManager $manager, Connection $connection, Statement $statement, ClassMetadata $classMetadata)
 {
     $connection->prepare(Argument::any())->willReturn($statement);
     $manager->getClassMetadata(Argument::any())->willReturn($classMetadata);
     $manager->getConnection()->willReturn($connection);
     $this->beConstructedWith($manager, 'pim_product_class');
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:CompletenessRepositorySpec.php

示例9: getDiff

 /**
  * @param Schema $targetSchema
  * @param \Doctrine\DBAL\Connection $connection
  * @return \Doctrine\DBAL\Schema\SchemaDiff
  */
 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     $platform = $connection->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer');
     $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer');
     return parent::getDiff($targetSchema, $connection);
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:12,代码来源:sqlitemigrator.php

示例10: loadAuthors

 protected function loadAuthors(Connection $connection)
 {
     $records = [['Thomas Hardy'], ['Terry Pratchett'], ['Malcolm Gladwell'], ['Charles Dickens']];
     foreach ($records as $r) {
         $connection->insert('authors', ['name' => $r[0]]);
     }
 }
开发者ID:glynnforrest,项目名称:active-doctrine,代码行数:7,代码来源:BookshopData.php

示例11: __construct

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

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

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

示例14: shutdown

 public function shutdown()
 {
     if ($this->connection->isTransactionActive()) {
         $this->rollback();
     }
     $this->connection->close();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:7,代码来源:TransactionalTestClient.php

示例15: fetch

 /**
  * @param QueryInterface $query
  * @return array
  */
 public function fetch(QueryInterface $query)
 {
     $query->checkReplacements();
     $plainQuery = $query->getPlainQuery();
     list($parameters, $plainQuery) = $this->modifyParametersFromArrayToScalar($query->getParameters(), $plainQuery);
     return $this->connection->fetchAll($plainQuery, $parameters);
 }
开发者ID:lsnova,项目名称:simple-query-executor,代码行数:11,代码来源:DbExecutor.php


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