當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::fetchAssoc方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Connection::fetchAssoc方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::fetchAssoc方法的具體用法?PHP Connection::fetchAssoc怎麽用?PHP Connection::fetchAssoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::fetchAssoc方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fetchByRoot

 public static function fetchByRoot(Connection $conn, $id, MembershipEntityInterface $root)
 {
     if ($root instanceof Area) {
         $data = $conn->fetchAssoc('SELECT * FROM `' . EdkTables::MESSAGE_TBL . '` WHERE `id` = :id AND `areaId` = :rootId', [':id' => $id, ':rootId' => $root->getId()]);
     } elseif ($root instanceof Group) {
         $data = $conn->fetchAssoc('SELECT m.* FROM `' . EdkTables::MESSAGE_TBL . '` m ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON a.`id` = m.`areaId` ' . 'WHERE m.`id` = :id AND a.`groupId` = :rootId', [':id' => $id, ':rootId' => $root->getId()]);
     } elseif ($root instanceof Project) {
         $data = $conn->fetchAssoc('SELECT m.* FROM `' . EdkTables::MESSAGE_TBL . '` m ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON a.`id` = m.`areaId` ' . 'WHERE m.`id` = :id AND a.`projectId` = :rootId', [':id' => $id, ':rootId' => $root->getId()]);
     }
     if (false === $data) {
         return false;
     }
     $item = self::fromArray($data);
     if ($root instanceof Area) {
         $item->area = $root;
     } elseif ($root instanceof Group) {
         $item->area = Area::fetchByGroup($conn, $data['areaId'], $root);
     } elseif ($root instanceof Project) {
         $item->area = Area::fetchByProject($conn, $data['areaId'], $root);
     }
     if (!empty($data['responderId'])) {
         $item->responder = User::fetchByCriteria($conn, QueryClause::clause('u.id = :id', ':id', $data['responderId']));
     }
     return $item;
 }
開發者ID:zyxist,項目名稱:cantiga,代碼行數:25,代碼來源:EdkMessage.php

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

示例3: findOne

 public function findOne($id)
 {
     $sql = "SELECT * FROM articles WHERE id = ?";
     $result = $this->db->fetchAssoc($sql, array((int) $id));
     $article = $this->buildArticle($result[0]);
     return $article;
 }
開發者ID:rocksolid-tn,項目名稱:SilexBlog,代碼行數:7,代碼來源:ArticleDAO.php

示例4: findByNameAndPassword

 public function findByNameAndPassword($admin)
 {
     $name = $admin->getName();
     $password = $admin->getPassword();
     $adminData = $this->db->fetchAssoc('SELECT * FROM admin WHERE name = ? and password = ?', array($name, $password));
     return $adminData ? $this->buildAdmin($adminData) : FALSE;
 }
開發者ID:yuyan2077,項目名稱:ResourcesStore,代碼行數:7,代碼來源:AdminRepository.php

示例5: count

 public function count()
 {
     $qb = $this->dbal->createQueryBuilder();
     $qb->select('count(*) c')->from('(' . $this->qb->getSQL() . ')', 'xxx');
     $row = $this->dbal->fetchAssoc($qb->getSQL());
     return $this->count = intval($row['c']);
 }
開發者ID:stopsopa,項目名稱:elastic,代碼行數:7,代碼來源:AbstractDbalProvider.php

示例6: findByUriValid

 public function findByUriValid($uri)
 {
     $sql = "SELECT * FROM {$this->entityTable} WHERE uri = ? AND compromised=0";
     $row = $this->db->fetchAssoc($sql, array((string) $uri));
     if ($row) {
         return $this->createEntity($row);
     }
 }
開發者ID:konstantin-s,項目名稱:silex-lazycache,代碼行數:8,代碼來源:CacheRecordSQLMapper.php

示例7: find

 public function find($id)
 {
     $record = $this->conn->fetchAssoc("SELECT id, message, author, parent FROM messages WHERE id = :id", [':id' => $id]);
     if (!$record) {
         throw new ObjectNotFoundException("Message not found for ID: {$id}");
     }
     return $record;
 }
開發者ID:abedsujan,項目名稱:zero-to-silex,代碼行數:8,代碼來源:MessageRepository.php

示例8: getCredentialChangeRequest

 public function getCredentialChangeRequest($id, User $currentUser)
 {
     $data = $this->conn->fetchAssoc('SELECT * FROM `' . CoreTables::CREDENTIAL_CHANGE_TBL . '` WHERE `id` = :id', [':id' => $id]);
     if (empty($data) || $data['userId'] != $currentUser->getId()) {
         throw new ModelException('The specified credential change request does not exist.');
     }
     return CredentialChangeRequest::fromArray($currentUser, $data);
 }
開發者ID:zyxist,項目名稱:cantiga,代碼行數:8,代碼來源:ProfileRepository.php

示例9: getFlowchartConfig

 /**
  * @param string $workflowId
  * @return array|null
  */
 public function getFlowchartConfig($workflowId)
 {
     $flowchartConfig = $this->connection->fetchAssoc("SELECT * FROM {$this->flowchartConfigTable} WHERE workflow_id = :id", ['id' => $workflowId]);
     if (!$flowchartConfig) {
         return null;
     }
     return ['workflow_id' => $flowchartConfig['workflow_id'], 'config' => json_decode($flowchartConfig['config']), 'last_updated_at' => $flowchartConfig['last_updated_at']];
 }
開發者ID:prooph,項目名稱:link-process-manager,代碼行數:12,代碼來源:FlowchartStore.php

示例10: findByUsername

 public function findByUsername($username)
 {
     $record = $this->conn->fetchAssoc("SELECT id, username, age FROM users WHERE username = :username", [':username' => $username]);
     if (!$record) {
         throw new ObjectNotFoundException("User not found for name: {$username}");
     }
     return $record;
 }
開發者ID:abedsujan,項目名稱:zero-to-silex,代碼行數:8,代碼來源:UserRepository.php

示例11: getVersion

 /**
  * @return string
  */
 public function getVersion()
 {
     $result = $this->connection->fetchAssoc('SELECT value AS version FROM pref WHERE prop="version"');
     if ($result !== false) {
         return $result['version'];
     }
     return VersionRepository::DEFAULT_VERSION;
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:11,代碼來源:DataboxVersionRepository.php

示例12: find

 /**
  * @param string $id
  * @return array|null
  */
 public function find($id)
 {
     $handlerData = $this->connection->fetchAssoc('SELECT * FROM ' . Tables::MESSAGE_HANDLER . ' WHERE id = :id', ['id' => $id]);
     if (empty($handlerData)) {
         return null;
     }
     $this->fromDatabase($handlerData);
     return $handlerData;
 }
開發者ID:prooph,項目名稱:link-process-manager,代碼行數:13,代碼來源:MessageHandlerFinder.php

示例13: fetchVocabularyByName

 public function fetchVocabularyByName($name)
 {
     $vocabulary = $this->dbal->fetchAssoc('SELECT * FROM taxonomyVocabulary WHERE name = :name', ['name' => $name]);
     if ($vocabulary) {
         $vocabulary = $this->vocabularyHydrator->hydrate($vocabulary, new Vocabulary());
         return $vocabulary;
     }
     throw new VocabularyNotFoundException('Could not find vocabulary ' . $name);
 }
開發者ID:dw250100785,項目名稱:webapp,代碼行數:9,代碼來源:TaxonomyService.php

示例14: getBySku

 /**
  * @param string $sku
  * @return Product
  * @throws QueryException
  */
 public function getBySku(string $sku) : Product
 {
     $qb = $this->connection->createQueryBuilder();
     $qb->select('*')->from('dumplie_inventory_product')->where('sku = :sku')->setParameter('sku', $sku);
     $productData = $this->connection->fetchAssoc($qb->getSQL(), $qb->getParameters());
     if (empty($productData)) {
         throw QueryException::productNotFound($sku);
     }
     return new Product($productData['sku'], $productData['price_amount'] / $productData['price_precision'], $productData['price_currency'], (bool) $productData['is_in_stock'], $this->mao->getBy([Metadata::FIELD_SKU => $productData['sku']]));
 }
開發者ID:dumplie,項目名稱:dumplie,代碼行數:15,代碼來源:DbalInventoryQuery.php

示例15: getBySku

 /**
  * @param SKU $sku
  * @return Product
  * @throws ProductNotFoundException
  */
 public function getBySku(SKU $sku) : Product
 {
     $queryBuilder = $this->connection->createQueryBuilder();
     $queryBuilder->select('sku', 'is_in_stock', 'price_amount', 'price_currency', 'price_precision')->from('dumplie_inventory_product')->where('sku = :sku')->setParameter('sku', (string) $sku);
     $result = $this->connection->fetchAssoc($queryBuilder->getSQL(), $queryBuilder->getParameters());
     if (!$result) {
         throw ProductNotFoundException::bySku($sku);
     }
     return new Product(new SKU($result['sku']), new Price((int) $result['price_amount'], $result['price_currency'], (int) $result['price_precision']), (bool) $result['is_in_stock']);
 }
開發者ID:dumplie,項目名稱:dumplie,代碼行數:15,代碼來源:DbalProducts.php


注:本文中的Doctrine\DBAL\Connection::fetchAssoc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。