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


PHP Connection::fetchAll方法代码示例

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


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

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

示例2: getRecentFrequent

 protected function getRecentFrequent(User $user, array $criteria = null, $limit = 10)
 {
     $sql = '
         SELECT text, MAX(createdAt) AS recency, COUNT(*) AS frequency
         FROM stress_log_factors
         JOIN stress_logs ON stress_log_id = stress_logs.id
         WHERE user_id = ?
     ';
     $params = array($user->getId());
     if (is_array($criteria)) {
         foreach ($criteria as $key => $val) {
             $op = '=';
             if (is_array($val)) {
                 reset($val);
                 $op = key($val);
                 $val = current($val);
             }
             $sql .= 'AND `' . $key . '` ' . $op . ' ? ';
             $params[] = $val;
         }
     }
     $sql .= 'GROUP BY text ';
     $sql .= 'ORDER BY recency DESC, frequency DESC ';
     $sql .= 'LIMIT ' . (int) $limit;
     $result = $this->conn->fetchAll($sql, $params);
     return array_column($result, 'text');
 }
开发者ID:jasongrimes,项目名称:stressmonkey,代码行数:27,代码来源:TagManager.php

示例3: getProductsByCategoryId

 /**
  * Получить продукты по ID категории
  *
  * @param $categoryId ID категории
  *
  * @return array
  */
 public function getProductsByCategoryId($categoryId)
 {
     return $this->db->fetchAll('SELECT `products`.* FROM `products`
             INNER JOIN `products_categories`
                 ON `products`.`id` = `products_categories`.`product_id`
         WHERE `products_categories`.`category_id` = ?', array($categoryId));
 }
开发者ID:Nakedspirit,项目名称:iShop,代码行数:14,代码来源:Catalog.php

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

示例5: findAll

 public function findAll()
 {
     $result = $this->db->fetchAll("select * from " . $this->table . ";");
     $event = new GenericEvent($result);
     $this->eventDispatcher->dispatch("post-findall-" . $this->entityName, $event);
     return $event->getSubject();
 }
开发者ID:fabricekabongo,项目名称:common,代码行数:7,代码来源:Repository.php

示例6: __call

 /**
  * Dispatches magic methods (findBy[Property]())
  *
  * @param string $methodName The name of the magic method
  * @param string $arguments The arguments of the magic method
  * @throws \Exception
  * @return mixed
  * @api
  */
 public function __call($methodName, $arguments)
 {
     if (substr($methodName, 0, 6) === 'findBy' && strlen($methodName) > 7) {
         $propertyName = lcfirst(substr($methodName, 6));
         $sql = "select * from " . $this->tableName . " where " . $propertyName . " = :propertyValue order by id desc";
         $result = $this->db->fetchAll($sql, array('propertyValue' => $arguments[0]));
         // Convert query result to an array of objects
         $objectList = array();
         foreach ($result as $row) {
             $id = $row['id'];
             $objectList[$id] = $this->buildDomainObject($row);
         }
         return $objectList;
     } elseif (substr($methodName, 0, 9) === 'findOneBy' && strlen($methodName) > 10) {
         $propertyName = lcfirst(substr($methodName, 9));
         $sql = "select * from " . $this->tableName . " where id = :id";
         $row = $this->db->fetchAssoc($sql, array('id' => $arguments[0]));
         if ($row) {
             return $this->buildDomainObject($row);
         } else {
             throw new \Exception("No " . $this->objectName . " matching  " . $propertyName . " " . $arguments[0]);
         }
     } elseif (substr($methodName, 0, 7) === 'countBy' && strlen($methodName) > 8) {
         $propertyName = lcfirst(substr($methodName, 7));
         $sql = "select COUNT(id) from " . $this->tableName . " where " . $propertyName . " = :propertyValue order by id desc";
         $result = current($this->db->fetchAssoc($sql, array('propertyValue' => $arguments[0])));
         return $result;
     }
     throw new \Exception('The method "' . $methodName . '" is not supported by the repository.', 1233180480);
 }
开发者ID:nicolastorre,项目名称:portfolio,代码行数:39,代码来源:Repository.php

示例7: indexAction

 public function indexAction()
 {
     //        $this->init($app);
     $posts = $this->db->fetchAll('SELECT * FROM post');
     //var_dump($posts);
     return $this->twig->render('post/index.twig', array('posts' => $posts));
 }
开发者ID:goshshitmailme,项目名称:php,代码行数:7,代码来源:PostController.php

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

示例9: collectData

 public function collectData(IdentifiableInterface $root)
 {
     $routes = $this->conn->fetchAll('SELECT `routeAscent` ' . 'FROM `' . EdkTables::ROUTE_TBL . '` r ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON r.`areaId` = a.`id` ' . 'WHERE a.`projectId` = :projectId AND r.`routeType` = 0', [':projectId' => $root->getId()]);
     if (sizeof($routes) == 0) {
         return false;
     }
     foreach ($routes as &$row) {
         $row['normalized'] = $this->step($row['routeAscent']);
     }
     $this->data = [];
     $min = 10000;
     $max = 0;
     foreach ($routes as $row) {
         if ($row['normalized'] < $min) {
             $min = $row['normalized'];
         }
         if ($row['normalized'] > $max) {
             $max = $row['normalized'];
         }
     }
     if ($min >= $max) {
         return false;
     }
     for ($i = $min; $i <= $max; $i++) {
         $this->data[$i] = 0;
     }
     foreach ($routes as $row) {
         $this->data[$row['normalized']]++;
     }
     return true;
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:31,代码来源:RouteAscentHistogram.php

示例10: findAll

 /**
  * Returns all records from this repository's table
  *
  * @param integer $limit
  *
  * @return array
  */
 public function findAll($limit = null)
 {
     if (null === $limit) {
         return $this->db->fetchAll(sprintf('SELECT * FROM %s', $this->getTableName()));
     }
     return $this->db->fetchAll(sprintf('SELECT * FROM %s LIMIT %d', $this->getTableName(), $limit));
 }
开发者ID:rkueny,项目名称:aperophp,代码行数:14,代码来源:Repository.php

示例11: findTasksOfMessageHandler

 /**
  * @param $messageHandlerId
  * @return array of task data
  */
 public function findTasksOfMessageHandler($messageHandlerId)
 {
     $tasks = $this->connection->fetchAll('SELECT * FROM ' . Tables::TASK . ' WHERE message_handler_id = :mhid', ['mhid' => $messageHandlerId]);
     foreach ($tasks as &$task) {
         $this->fromDatabase($task);
     }
     return $tasks;
 }
开发者ID:prooph,项目名称:link-process-manager,代码行数:12,代码来源:TaskFinder.php

示例12: getAll

 /**
  * @return Exercise[]
  */
 public function getAll()
 {
     $exercises = [];
     foreach ($this->connection->fetchAll('SELECT id, title, description FROM exercises') as $data) {
         $exercises[] = new Exercise($data['id'], $data['title'], $data['description']);
     }
     return $exercises;
 }
开发者ID:jehaby,项目名称:exesise,代码行数:11,代码来源:ExercisesRepository.php

示例13: getTableNames

 private function getTableNames()
 {
     $tableNames = [];
     foreach ($this->connection->fetchAll('SHOW TABLES') as $row) {
         $tableNames[] = $row['Tables_in_' . $this->connection->getDatabase()];
     }
     return $tableNames;
 }
开发者ID:AlexValGal,项目名称:Practica-FInal-DIW-DWC,代码行数:8,代码来源:SchemaGenerator.php

示例14: getProjects

 /**
  * @param string $organisation
  * @param string $project
  *
  * @return array
  */
 public function getProjects($organisation, $project)
 {
     if (false === empty($project)) {
         return [$project];
     }
     $projects = $this->connection->fetchAll('SELECT project FROM events WHERE organisation = ? GROUP BY project', [$organisation]);
     return array_column($projects, 'project');
 }
开发者ID:enlightened-dc,项目名称:sentry-monitor,代码行数:14,代码来源:ProjectFinder.php

示例15: fetch

 /**
  * @param Contract $streamContract
  * @param Identifier $streamId
  * @return EventEnvelope[]
  */
 public function fetch(Contract $streamContract, Identifier $streamId)
 {
     $records = $this->connection->fetchAll(Query\Select::from(self::TABLE_NAME), ['streamContract' => $streamContract, 'streamId' => $streamId]);
     $eventEnvelopes = array_map(function (array $record) {
         return EventEnvelope::reconstitute(EventId::fromString($record['eventId']), Contract::with($record['eventContract']), $record['eventPayload']);
     }, $records);
     return $eventEnvelopes;
 }
开发者ID:dpsarrou,项目名称:EventCentric.Core,代码行数:13,代码来源:MySQLPersistence.php


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