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


PHP Connection::query方法代码示例

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


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

示例1: read

 /**
  * @return array|null
  */
 public function read()
 {
     if (is_null($this->stmt)) {
         $this->stmt = $this->connection->query("SELECT * FROM products");
     }
     return $this->stmt->fetch();
 }
开发者ID:AlexandrKozyr,项目名称:oops_test,代码行数:10,代码来源:Product.php

示例2: query

 /**
  * {@inheritdoc}
  */
 public function query($query, $resultsetType = Resultset::TYPE_ARRAY)
 {
     // This error may happen with the libmysql instead of mysqlnd and using set statement (set @test=1)
     // : "Attempt to read a row while there is no result set associated with the statement"
     try {
         /**
          * @var \Doctrine\DBAL\Driver\Mysqli\MysqliStatement
          */
         $r = $this->dbal->query($query);
         $results = new Resultset($resultsetType);
         if ($r === false) {
             throw new Exception\InvalidArgumentException("Query cannot be executed [{$query}].");
         } else {
             if ($r->columnCount() > 0) {
                 while ($row = $r->fetch()) {
                     $results->append((array) $row);
                 }
             }
         }
     } catch (\Exception $e) {
         $msg = "Doctrine\\Dbal2 adapter query error: {$e->getMessage()} [{$query}]";
         throw new Exception\InvalidArgumentException($msg);
     }
     return $results;
 }
开发者ID:belgattitude,项目名称:soluble-dbwrapper,代码行数:28,代码来源:Dbal2Adapter.php

示例3: createTable

 public function createTable($name)
 {
     // remove table
     $pdo = $this->pdo->query('DROP TABLE IF EXISTS `' . $name . '`;');
     $pdo->execute();
     // create table
     $newSchema = new \Doctrine\DBAL\Schema\Schema();
     $newTable = $newSchema->createTable($name);
     $newTable->addColumn('container_id', 'integer');
     $newTable->addColumn('context_id', 'integer');
     $newTable->addColumn('module_id', 'integer');
     $newTable->addColumn('resource_id', 'integer')->setNotnull(false);
     $newTable->addColumn('by_resource_id', 'integer')->setNotnull(false);
     $newTable->addColumn('sequence', 'integer')->setNotnull(false);
     $newTable->addColumn('deleted', 'datetime')->setNotnull(false);
     $newTable->addColumn('display', 'boolean')->setNotnull(true);
     $newTable->addColumn('expire_temporary_date', 'datetime')->setNotnull(false);
     $newTable->addColumn('culture', 'string')->setLength(11);
     foreach ($this->eavColumns->getColumns() as $column) {
         if ($this->getTypeToColumn($column['column'])) {
             $newTable->addColumn($column['identifier'], $this->getTypeToColumn($column['column']))->setNotnull(false);
             $columnsToFill[] = $column['identifier'];
         }
     }
     $newTable->addForeignKeyConstraint($this->objectManager->getClassMetadata('BigfishEavBundle:Container')->getTablename(), array('container_id'), array('container_id'), array('onDelete' => 'CASCADE'));
     $newTable->addForeignKeyConstraint($this->objectManager->getClassMetadata('BigfishEavBundle:Module')->getTablename(), array('module_id'), array('module_id'), array('onDelete' => 'CASCADE'));
     $newTable->addForeignKeyConstraint($this->objectManager->getClassMetadata('BigfishContextBundle:Context')->getTablename(), array('context_id'), array('context_id'), array('onDelete' => 'CASCADE'));
     $newTable->addForeignKeyConstraint($this->objectManager->getClassMetadata('BigfishResourceBundle:Resource')->getTablename(), array('resource_id'), array('resource_id'), array('onDelete' => 'CASCADE'));
     $newTable->addForeignKeyConstraint($this->objectManager->getClassMetadata('BigfishResourceBundle:Resource')->getTablename(), array('by_resource_id'), array('resource_id'), array('onDelete' => 'CASCADE'));
     foreach ($newSchema->toSql($this->objectManager->getConnection()->getDatabasePlatform()) as $l) {
         $pdo = $this->pdo->prepare($l);
         $pdo->execute();
     }
 }
开发者ID:bigfishcmf,项目名称:bigfishcmf,代码行数:34,代码来源:FlatternTable.php

示例4: runQuery

 /**
  * @param $sql
  * @return \Doctrine\DBAL\Driver\Statement
  * @throws \Doctrine\DBAL\DBALException
  */
 public static function runQuery($sql)
 {
     if (null === static::$dblaConnInstance) {
         static::$dblaConnInstance = DriverManager::getConnection(static::getParamsConnection(), new Configuration());
         static::$dblaConnInstance->getConfiguration()->setSQLLogger(self::logger());
     }
     return static::$dblaConnInstance->query($sql);
 }
开发者ID:lacteosdelcesar,项目名称:s3-untitledApi-K,代码行数:13,代码来源:EntityManager.php

示例5: createIndexes

 /**
  * @return bool
  */
 public function createIndexes()
 {
     try {
         $this->connection->query($this->getQuery());
     } catch (DBALException $exception) {
         return false;
     }
     return true;
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:FulltextIndexManager.php

示例6: doHealthCheck

 /**
  * Actual health check logic.
  *
  * @param HealthBuilder $builder
  *
  * @throws \Exception any Exception that should create a Status::DOWN
  *                    system status.
  */
 protected function doHealthCheck(HealthBuilder $builder)
 {
     try {
         $this->connection->query('SELECT 1=1');
     } catch (DBALException $e) {
         $builder->down($e);
         return;
     }
     $builder->up();
 }
开发者ID:postalservice14,项目名称:php-actuator,代码行数:18,代码来源:DoctrineConnectionHealthIndicator.php

示例7: getAll

 /**
  * @return Job[]
  */
 public function getAll()
 {
     $this->conn->connect();
     $stmt = $this->conn->query("select * from {$this->table_name}");
     $stmt->setFetchMode(\PDO::FETCH_CLASS, '\\ebussola\\job\\job\\Job');
     $stmt->execute();
     $jobs = $stmt->fetchAll();
     $this->conn->close();
     return $jobs;
 }
开发者ID:ebussola,项目名称:job-schedule-se,代码行数:13,代码来源:Doctrine.php

示例8: getResponsiveTemplateId

 /**
  * @return int
  */
 private function getResponsiveTemplateId()
 {
     $statement = $this->conn->query('SELECT id FROM s_core_templates WHERE template LIKE "Responsive"');
     $statement->execute();
     $templateId = $statement->fetchColumn(0);
     if (!$templateId) {
         throw new \RuntimeException("Could not get id for default template");
     }
     return (int) $templateId;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:13,代码来源:ThemeInitializeCommand.php

示例9: loadUserTableWithOneItem

 public function loadUserTableWithOneItem()
 {
     if ($this->isDbPrepared) {
         return;
     }
     $this->connection->query('CREATE TABLE user (id INTEGER NOT NULL, name string, PRIMARY KEY(id))');
     $user = new User('John');
     $this->entityManager->persist($user);
     $this->entityManager->flush();
     $this->isDbPrepared = TRUE;
 }
开发者ID:MartinSadovy,项目名称:nette-identity-doctrine,代码行数:11,代码来源:DatabaseLoader.php

示例10: run

 public function run()
 {
     $success = true;
     foreach ($this->queries as $sql) {
         if (strlen($sql) > 0) {
             if (!$this->db->query($sql)) {
                 $success = false;
             }
         }
     }
     return $success;
 }
开发者ID:adamgajzlerowicz,项目名称:migrateur,代码行数:12,代码来源:MigrationService.php

示例11: execCommand

 /**
  * Executes a command.
  *
  * @param string $hash
  *
  * @throws \InvalidArgumentException
  */
 public function execCommand($hash)
 {
     if (null === $this->commands) {
         $this->compileCommands();
     }
     foreach ($this->commands as $commands) {
         if (isset($commands[$hash])) {
             $this->connection->query($commands[$hash]);
             return;
         }
     }
     throw new \InvalidArgumentException(sprintf('Invalid hash: %s', $hash));
 }
开发者ID:contao,项目名称:installation-bundle,代码行数:20,代码来源:Installer.php

示例12: emptyOrderedToolRoleTable

 private function emptyOrderedToolRoleTable()
 {
     $this->log('emptying claro_ordered_tool_role table...');
     $this->connection->query('SET FOREIGN_KEY_CHECKS=0');
     $this->connection->query('TRUNCATE TABLE claro_ordered_tool_role');
     $this->connection->query('SET FOREIGN_KEY_CHECKS=1');
 }
开发者ID:claroline,项目名称:distribution,代码行数:7,代码来源:Updater030800.php

示例13: execute

 protected function execute()
 {
     if ($this->currentStatement === null) {
         $this->currentStatement = $this->db->query($this->buildQuery());
         $this->rowCount = $this->currentStatement->rowCount();
     }
     return $this->currentStatement;
 }
开发者ID:buldezir,项目名称:dja_orm,代码行数:8,代码来源:DataIterator.php

示例14: commit

 /**
  * Runs the changes to the schema
  */
 public function commit()
 {
     $this->connection->beginTransaction();
     foreach ($this->getChanges() as $sql) {
         $this->connection->query($sql);
     }
     $this->connection->commit();
 }
开发者ID:KasaiDot,项目名称:FoolFrame,代码行数:11,代码来源:SchemaManager.php

示例15: getDatabase

 /**
  * {@inheritdoc}
  */
 public function getDatabase(\Doctrine\DBAL\Connection $conn)
 {
     $params = $conn->getParams();
     if (isset($params['dbname'])) {
         return $params['dbname'];
     }
     return $conn->query('SELECT DB_NAME()')->fetchColumn();
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:11,代码来源:AbstractSQLServerDriver.php


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