Doctrine\DBAL\Connection::fetchAssoc PHP Method

fetchAssoc() public method

Prepares and executes an SQL query and returns the first row of the result as an associative array.
public fetchAssoc ( string $statement, array $params = [], array $types = [] ) : array | boolean
$statement string The SQL query.
$params array The query parameters.
$types array The query parameter types.
return array | boolean False is returned if no rows are found.
    public function fetchAssoc($statement, array $params = array(), array $types = array())
    {
        return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_ASSOC);
    }

Usage Example

コード例 #1
0
ファイル: EdkMessage.php プロジェクト: zyxist/cantiga
 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;
 }
All Usage Examples Of Doctrine\DBAL\Connection::fetchAssoc