Symfony返回第一个元素数组

时间:2017-09-08 09:54:13

标签: php database symfony

    /**
     * @return mixed
     */
    public function getAll()
    {
        return $this->getLic();
    }

    /**
     * @return mixed
     */
    private function getLic()
    {
        try {
            $conn = $this->db->getPDO()->prepare("SELECT * FROM table");
            $conn->execute();
            $query = $conn->fetch(\PDO::FETCH_ASSOC);
        } catch (\PDOException $exception) {
            throw new \PDOException($exception->getMessage());
        }
        echo json_encode($query, JSON_OBJECT_AS_ARRAY);

        return $query;
    }

结果应为:

{{11:1, 11:1, 11:1}, {12:2, 22:2, 32:2,}, {13:3, 23:3, 33:3}}

但它返回:

{11:1, 11:1, 11:1}

0 个答案:

没有答案