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


PHP Connection::executeQuery方法代码示例

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


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

示例1: exportData

 public function exportData($export, $reporter)
 {
     $this->conn->beginTransaction();
     try {
         $lastExportedAt = (int) $export['lastExportedAt'];
         $areas = $this->conn->fetchAll('SELECT a.`id`, a.`name`, t.`id` AS `territoryId`, t.`name` AS `territoryName`, a.`customData`, a.`lastUpdatedAt` ' . 'FROM `' . CoreTables::AREA_TBL . '` a ' . 'INNER JOIN `' . CoreTables::TERRITORY_TBL . '` t ON t.`id` = a.`territoryId` ' . 'WHERE a.`projectId` = :projectId AND a.`statusId` = :statusId', [':projectId' => $export['projectId'], ':statusId' => $export['areaStatusId']]);
         $block = new ExportBlock();
         foreach ($areas as $area) {
             $block->addId($area['id']);
             if ($area['lastUpdatedAt'] > $lastExportedAt) {
                 $area['customData'] = json_decode($area['customData']);
                 $block->addUpdatedId($area['id']);
                 $block->addUpdate($area);
             }
         }
         $event = new ExportEvent($export['projectId'], $export['lastExportedAt'], $reporter);
         $event->addBlock('area', $block);
         $event = $this->eventDispatcher->dispatch(ExportEvents::EXPORT_ONGOING, $event);
         $this->conn->executeQuery('UPDATE `' . ExportTables::DATA_EXPORT_TBL . '` SET `lastExportedAt` = :time WHERE `id` = :id', [':time' => time(), ':id' => $export['id']]);
         $this->conn->commit();
         return $event->output();
     } catch (Exception $ex) {
         $this->conn->rollBack();
         throw $ex;
     }
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:26,代码来源:ExportEngine.php

示例2: exportTableList

 function exportTableList()
 {
     return array_map(function ($row) {
         $values = array_values($row);
         return $values[0];
     }, $this->db->executeQuery('SHOW TABLES')->fetchAll());
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:export-db.php

示例3: doExecute

 /**
  * @param LoggerInterface $logger
  * @param bool $dryRun
  */
 protected function doExecute(LoggerInterface $logger, $dryRun = false)
 {
     $duplicateEntitiesQuery = 'SELECT
             DISTINCT t2.id
         FROM
             orocrm_campaign_email_stats AS t1
         LEFT JOIN orocrm_campaign_email_stats AS t2
             ON t1.email_campaign_id = t2.email_campaign_id
             AND t1.marketing_list_item_id = t2.marketing_list_item_id
             AND t2.id > t1.id
         WHERE t2.id IS NOT NULL';
     // Done in 2 queries for cross DB support.
     $idsToRemove = array_map(function ($item) {
         if (is_array($item) && array_key_exists('id', $item)) {
             return $item['id'];
         }
         return null;
     }, $this->connection->fetchAll($duplicateEntitiesQuery));
     if ($idsToRemove) {
         $query = 'DELETE FROM orocrm_campaign_email_stats WHERE id IN (?)';
         $logger->notice($query);
         if (!$dryRun) {
             $this->connection->executeQuery($query, [$idsToRemove], [Connection::PARAM_INT_ARRAY]);
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:30,代码来源:AggregateStatisticsQuery.php

示例4: execute

 /**
  * @param QueryInterface $query
  * @return int
  */
 public function execute(QueryInterface $query)
 {
     $query->checkReplacements();
     $plainQuery = $query->getPlainQuery();
     list($parameters, $plainQuery) = $this->modifyParametersFromArrayToScalar($query->getParameters(), $plainQuery);
     return $this->connection->executeQuery($query->getPlainQuery(), $parameters);
 }
开发者ID:lsnova,项目名称:simple-query-executor,代码行数:11,代码来源:DbExecutor.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: updateStatus

 /**
  * Update status
  *
  * @param string $nonce
  * @param string $apiUrls
  *
  * @return int
  */
 public function updateStatus($nonce, $apiUrls)
 {
     // Truncate table
     $this->con->executeQuery($this->con->getDatabasePlatform()->getTruncateTableSQL($this->tables['status']));
     // Insert new row
     return $this->con->insert($this->tables['status'], array('nonce' => $nonce, 'noncets' => time(), 'apiurls' => $apiUrls, 'modified' => new \DateTime()), array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_STR, 'datetime'));
 }
开发者ID:albancrommer,项目名称:acmephpc,代码行数:15,代码来源:DoctrineDbal.php

示例7: getConnection

 /**
  * Retrieves hte index database.
  *
  * @return Connection
  */
 public function getConnection()
 {
     if (!$this->connection) {
         $isNewDatabase = !file_exists($this->databasePath);
         $configuration = new Configuration();
         $this->connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => $this->databasePath], $configuration);
         $outOfDate = null;
         if ($isNewDatabase) {
             $this->createDatabaseTables($this->connection);
             // NOTE: This causes a database write and will cause locking problems if multiple PHP processes are
             // spawned and another one is also writing (e.g. indexing).
             $this->connection->executeQuery('PRAGMA user_version=' . $this->databaseVersion);
         } else {
             $version = $this->connection->executeQuery('PRAGMA user_version')->fetchColumn();
             if ($version < $this->databaseVersion) {
                 $this->connection->close();
                 $this->connection = null;
                 @unlink($this->databasePath);
                 return $this->getConnection();
                 // Do it again.
             }
         }
     }
     // Have to be a douche about this as these PRAGMA's seem to reset, even though the connection is not closed.
     $this->connection->executeQuery('PRAGMA foreign_keys=ON');
     // Data could become corrupted if the operating system were to crash during synchronization, but this
     // matters very little as we will just reindex the project next time. In the meantime, this majorly reduces
     // hard disk I/O during indexing and increases indexing speed dramatically (dropped from over a minute to a
     // couple of seconds for a very small (!) project).
     $this->connection->executeQuery('PRAGMA synchronous=OFF');
     return $this->connection;
 }
开发者ID:tocjent,项目名称:php-integrator-base,代码行数:37,代码来源:IndexDatabase.php

示例8: fetchRows

 private function fetchRows()
 {
     $statement = $this->connection->executeQuery($this->getSQLForAllRows());
     $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
     $statement->closeCursor();
     return $rows;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:DbalDataboxFieldRepository.php

示例9: runSQL

 /**
  * Proxy method to connection object. If an error occurred because of unfound table, tries to create table and rerun request.
  *
  * @param string $query      SQL query
  * @param array  $parameters query parameters
  */
 protected function runSQL($query, array $parameters = array())
 {
     try {
         return $this->connection->executeQuery($query, $parameters);
     } catch (\Exception $e) {
         $this->connection->executeQuery(sprintf('CREATE TABLE %s (`key` VARCHAR(40), `value` TEXT);', $this->tableName));
     }
     return $this->connection->executeQuery($query, $parameters);
 }
开发者ID:phecho,项目名称:gitonomy,代码行数:15,代码来源:MysqlConfig.php

示例10: runSQL

 /**
  * Proxy method to connection object. If an error occurred because of unfound table, tries to create table and rerun request.
  *
  * @param string $query      SQL query
  * @param array  $parameters query parameters
  */
 protected function runSQL($query, array $parameters = array())
 {
     try {
         return $this->connection->executeQuery($query, $parameters);
     } catch (\Exception $e) {
         $this->connection->executeQuery(sprintf(self::TABLE_CREATE, $this->tableName));
     }
     return $this->connection->executeQuery($query, $parameters);
 }
开发者ID:phecho,项目名称:gitonomy,代码行数:15,代码来源:MysqlJobStorage.php

示例11: update

 /**
  * @inheritdoc
  */
 public function update()
 {
     try {
         $constraint = $this->getForeignKeyConstraint('s_import_export_session', 'log_id');
         $this->dbalConnection->executeQuery('ALTER TABLE s_import_export_session DROP FOREIGN KEY ' . $constraint);
     } catch (\Exception $exception) {
     }
     $this->dbalConnection->executeQuery('ALTER TABLE s_import_export_session DROP COLUMN log_id');
     $this->removeImportFilesAlbum();
 }
开发者ID:shopwareLabs,项目名称:SwagImportExport,代码行数:13,代码来源:Update02RemoveForeignKeyConstraint.php

示例12: onAreaRequestStatusChange

 /**
  * Updates the statistics for area requests in the current day.
  * 
  * @param \Cantiga\CoreBundle\Repository\AreaRequestEvent $event
  */
 public function onAreaRequestStatusChange(AreaRequestEvent $event)
 {
     $project = $event->getAreaRequest()->getProject();
     $values = [0 => 0, 1 => 0, 2 => 0, 3 => 0];
     $calculated = $this->conn->fetchAll('SELECT `status`, COUNT(`id`) AS `counted` FROM `' . CoreTables::AREA_REQUEST_TBL . '` WHERE `projectId` = :projectId GROUP BY `status`', [':projectId' => $project->getId()]);
     foreach ($calculated as $row) {
         $values[$row['status']] = $row['counted'];
     }
     $date = date('Y-m-d');
     $this->conn->executeQuery('INSERT INTO `' . CoreTables::STAT_ARQ_TIME_TBL . '` (`projectId`, `datePoint`, `requestsNew`, `requestsVerification`, `requestsApproved`, `requestsRejected`)' . 'VALUES(:projectId, :datePoint, :rn1, :rv1, :ra1, :rr1) ON DUPLICATE KEY UPDATE `requestsNew` = :rn2, `requestsVerification` = :rv2, `requestsApproved` = :ra2, `requestsRejected` = :rr2', [':projectId' => $project->getId(), ':datePoint' => $date, ':rn1' => $values[AreaRequest::STATUS_NEW], ':rv1' => $values[AreaRequest::STATUS_VERIFICATION], ':ra1' => $values[AreaRequest::STATUS_APPROVED], ':rr1' => $values[AreaRequest::STATUS_REVOKED], ':rn2' => $values[AreaRequest::STATUS_NEW], ':rv2' => $values[AreaRequest::STATUS_VERIFICATION], ':ra2' => $values[AreaRequest::STATUS_APPROVED], ':rr2' => $values[AreaRequest::STATUS_REVOKED]]);
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:16,代码来源:CoreStatisticsRepository.php

示例13: create

 /**
  */
 public function create()
 {
     $createTableSql = 'CREATE TABLE IF NOT EXISTS events (
         organisation TEXT,
         project TEXT,
         event_id INTEGER,
         created TEXT,
         UNIQUE(organisation, project, event_id, created)
     )';
     $this->connection->executeQuery($createTableSql);
 }
开发者ID:enlightened-dc,项目名称:sentry-monitor,代码行数:13,代码来源:EventTable.php

示例14: selectByKey

 /**
  * @param $table
  * @param $primaryKeyName
  * @param $keyName
  * @param $keyValues
  * @return array
  * @throws \Doctrine\DBAL\DBALException
  */
 public function selectByKey($table, $primaryKeyName, $keyName, $keyValues)
 {
     $basicSql = "SELECT * FROM `{$table}`";
     if (!empty($keyValues)) {
         $where = " WHERE {$keyName} IN (?)";
         $statement = $this->connection->executeQuery($basicSql . $where, [$keyValues], [\Doctrine\DBAL\Connection::PARAM_INT_ARRAY]);
     } else {
         $statement = $this->connection->executeQuery($basicSql);
     }
     return $statement->fetchAll(\PDO::FETCH_ASSOC);
 }
开发者ID:mikron-ia,项目名称:rpg-hub-system,代码行数:19,代码来源:MySqlStorageEngine.php

示例15: build

 /**
  * @param string $className
  */
 public function build($className)
 {
     if ($this->reflectionService->isClassAnnotatedWith($className, Table::class) === FALSE) {
         throw new \InvalidArgumentException('The class "' . $className . '" is not annotated properly.', 1428331094);
     }
     /** @var Table $table */
     $table = $this->reflectionService->getClassAnnotation($className, Table::class);
     $query = $this->createTableDefinitionQueryForClassName($className);
     $this->databaseConnection->executeQuery('DROP TABLE IF EXISTS ' . $table->name);
     $this->databaseConnection->executeQuery($query);
 }
开发者ID:flow2lab,项目名称:eventsourcing,代码行数:14,代码来源:ProjectionBuilder.php


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