Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.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 类SQLite3Result的对象无法转换为int(COUNT和EXISTS)_Php_Html_Mysql_Database_Sqlite - Fatal编程技术网

Php 类SQLite3Result的对象无法转换为int(COUNT和EXISTS)

Php 类SQLite3Result的对象无法转换为int(COUNT和EXISTS),php,html,mysql,database,sqlite,Php,Html,Mysql,Database,Sqlite,伙计们,我想做的是检测一个数据是否存在,但我得到的是结果不能转换成int。 “无法在中将类SQLite3Result的对象转换为int” 代码如下: $result = $db->query('SELECT EXISTS (SELECT 1 FROM authorized_personnel WHERE Username = $username);'); //i've also tried COUNT(*) and i'm getting the same error s

伙计们,我想做的是检测一个数据是否存在,但我得到的是结果不能转换成int。 “无法在中将类SQLite3Result的对象转换为int”

代码如下:

 $result = $db->query('SELECT EXISTS (SELECT 1 FROM authorized_personnel WHERE Username = $username);'); //i've also tried COUNT(*) and i'm getting the same error
        settype($result, "integer"); //i've also tried putting and removing settype() and im getting the same error
        if ($result == 1)
        {
            echo "found";
        }
        else if ($result == 0)
        {
            echo "not found";
        }

伙计们,我应该在条件语句中添加什么?

这是否回答了您的问题?