Press Ctrl-C to quit. Start success.
1PDOException: SQL:SELECT id FROM collect_device WHERE unique_identification_number= user SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user' in 'where clause' in C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\Connection.php:1774
Stack trace:
0 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\Connection.php(1954): Workerman\MySQL\Connection->execute('SELECT id FROM ...', Array)
process C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\start_businessworker.php terminated and try to restart
报了这一堆
报什么错误提示?
Press Ctrl-C to quit. Start success.
1PDOException: SQL:SELECT id FROM
collect_device
WHERE unique_identification_number= user SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user' in 'where clause' in C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\Connection.php:1774Stack trace:
0 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\Connection.php(1954): Workerman\MySQL\Connection->execute('SELECT id FROM ...', Array)
1 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\Events.php(81): Workerman\MySQL\Connection->single()
2 [internal function]: Events::onMessage('7f0000010b54000...', '{"type":"bind",...')
3 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\gateway-worker-for-win\src\BusinessWorker.php(384): call_user_func('Events::onMessa...', '7f0000010b54000...', '{"type":"bind",...')
4 [internal function]: GatewayWorker\BusinessWorker->onGatewayMessage(Object(Workerman\Connection\AsyncTcpConnection), Array)
5 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\workerman-for-win\Connection\TcpConnection.php(629): call_user_func(Array, Object(Workerman\Connection\AsyncTcpConnection), Array)
6 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #28)
7 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\workerman-for-win\Events\Select.php(286): call_user_func_array(Array, Array)
8 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\workerman-for-win\Worker.php(856): Workerman\Events\Select->loop()
9 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\gateway-worker-for-win\src\BusinessWorker.php(190): Workerman\Worker->run()
10 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\workerman-for-win\Worker.php(473): GatewayWorker\BusinessWorker->run()
11 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\vendor\workerman\workerman-for-win\Worker.php(382): Workerman\Worker::runAllWorkers()
12 C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\start_businessworker.php(35): Workerman\Worker::runAll()
13 {main}
process C:\phpStudy\PHPTutorial\WWW\kaiwu\vendor\GatewayWorker-for-win\Applications\YourApp\start_businessworker.php terminated and try to restart
报了这一堆
SELECT id FROM collect_device WHERE unique_identification_number= user 语句感觉有点奇怪 这个 user 是什么啊?
unique_identification_number 这个是int型字段string字段类型?
报的错误是 collect_device 这个表中无 user 字段
我要在表中查找unique_identification_number(varchar)的值为user的一条数据
哥 加单引号才可以 不然数据库会认为 user是字段名,不是 值
$db->select('ID')->from('Persons')->where("sex= 'F' ")->single(); 例如这样子
getawayworker数据查询查询不到的时候会直接报错吗,我想知道我遇到的这个错误正不正常。有没有办法判断表中是不是已经存在某条数据。谢谢了
不会,你这是SQL语句错误
然后再根据查询的结果判断是否存在
没有报错了,多谢。因为我在代码里那个位置添的是$fromid,所以没加''.我直到现在也不是很明白,我加的$fromid确实是个变量。按照你说的问题确实解决了,万分感谢
这样写容易sql注入,最好按照手册 bindValues 那样传参数
$fromid 如果不加单引号,会直接认为是一个 字段名称的
明白了