Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php SQLite3查询失败_Php_Sqlite - Fatal编程技术网

Php SQLite3查询失败

Php SQLite3查询失败,php,sqlite,Php,Sqlite,SQLite3查询失败。在数据库中插入数据可以,但是没有得到数据,这是我的错吗 protected function db2Array($data) { $arr = array(); while ($row = $data -> fetchArray(\SQLITE3_ASSOC)) { $arr[] = $row; } return $arr; } function getNews() { try {

SQLite3查询失败。在数据库中插入数据可以,但是没有得到数据,这是我的错吗

protected function db2Array($data)
{
    $arr = array();
    while ($row = $data -> fetchArray(\SQLITE3_ASSOC))
    {
        $arr[] = $row;
    }
    return $arr;
}

function getNews()
{
    try
    {
        $sql = "SELECT msgs.id as id, 
                       title, 
                       category.name as category, 
                       description, 
                       source, 
                       datetime
                  FROM msgs,
                       category
                 WHERE category.id = msgs.category
              ORDER BY msgs.id DESC";
        $res = $this->_db -> query($sql);
        if(!is_object($res))
        {
            throw new Exception ($this->_db -> LastErrorMsg());
        }
        return $this->db2Array($res);
    }
    catch (Exception $exs)
    {
        //$exs -> getMessage();
        return FALSE;
    }
}

此代码返回:array(size=0)empty

直接运行查询时是否返回记录?是否尝试在末尾使用分号?是,正确添加到数据库。添加了一个准备好的查询对不起,我不懂分号。哪里?
添加什么?这是选择查询,不是插入查询。