首页
下载
文档
问答社区
视频
捐赠
源代码
AI 助理
赞助商
CRMEB
Apipost
腾讯云
微擎
禅道
51Talk
商业产品
Swoole AI 智能文档翻译器
Swoole-Compiler PHP 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
这个Undefined offset: 1 报错是怎么回事。谢谢!
### 鲁飞大神,麻烦你帮我看看这个Undefined offset: 1 报错怎么回事 ### 相关代码 ```php $o = 10; $n = (int)$event['name']; if ($n == 10 || $n == 20 || $n == 30 || $n == 40 || $n == 50 || $n == 60 || $n == 70 || $n == 80 || $n == 90) { $t = ($n + $o); var_dump($t); $model = Db::table('devices')->where('device_name', ($t))->field('device_model')->find(); var_dump($model); $event['name']=$model; $fds = Db::table('devices')->where('device_model', $event['name'])->field('device_fd')->select()->toArray(); if (count($fds) > 0) { $to = array(); for ($x = 0; $x < count($fds); $x++) { array_push($to, $fds[$x]['device_fd']); } $ws->to($to)->emit('pi_callback', $event['msg']); $ws->emit('pi_callback', $event['msg']); } else { //进行更新操作 Db::table('devices')->where('device_name', ($n))->update(['device_task' => $event['task'],]); //发送消息到主控端让主控端刷新 $device = Db::table('devices')->where('device_name', 'admin')->find(); if ($device['device_status'] == 1) { $ws->to($device['device_fd'])->emit('add_callback', '刷新页面'); } } } } } ``` ###这里报错了 [think\exception\ErrorException] ```php Undefined offset: 1 Exception trace: () at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:493 think\initializer\Error->appError() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:493 think\db\Builder->parseWhereItem() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:386 think\db\Builder->parseWhereLogic() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:331 think\db\Builder->buildWhere() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:299 think\db\Builder->parseWhere() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/builder/Mysql.php:94 think\db\builder\Mysql->select() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/PDOConnection.php:916 think\db\PDOConnection->think\db\{closure}() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/PDOConnection.php:699 think\db\PDOConnection->pdoQuery() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/PDOConnection.php:917 think\db\PDOConnection->select() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/BaseQuery.php:1090 think\db\BaseQuery->select() at /www/wwwroot/tp/app/listener/WsTest.php:56 app\listener\WsTest->handle() at n/a:n/a ReflectionMethod->invokeArgs() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:328 think\Container->invokeMethod() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:361 think\Container->invoke() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Event.php:260 think\Event->dispatch() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Event.php:221 think\Event->trigger() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/concerns/InteractsWithWebsocket.php:91 think\swoole\Manager->think\swoole\concerns\{closure}() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:293 think\Container->invokeFunction() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:357 think\Container->invoke() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/Sandbox.php:84 think\swoole\Sandbox->run() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/concerns/WithApplication.php:112 think\swoole\Manager->runInSandbox() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/concerns/InteractsWithWebsocket.php:94 ```
发布于3年前 · 13 次浏览 · 来自
提问
菜鸟V0
### 鲁飞大神,麻烦你帮我看看这个Undefined offset: 1 报错怎么回事 ### 相关代码 ```php $o = 10; $n = (int)$event['name']; if ($n == 10 || $n == 20 || $n == 30 || $n == 40 || $n == 50 || $n == 60 || $n == 70 || $n == 80 || $n == 90) { $t = ($n + $o); var_dump($t); $model = Db::table('devices')->where('device_name', ($t))->field('device_model')->find(); var_dump($model); $event['name']=$model; $fds = Db::table('devices')->where('device_model', $event['name'])->field('device_fd')->select()->toArray(); if (count($fds) > 0) { $to = array(); for ($x = 0; $x < count($fds); $x++) { array_push($to, $fds[$x]['device_fd']); } $ws->to($to)->emit('pi_callback', $event['msg']); $ws->emit('pi_callback', $event['msg']); } else { //进行更新操作 Db::table('devices')->where('device_name', ($n))->update(['device_task' => $event['task'],]); //发送消息到主控端让主控端刷新 $device = Db::table('devices')->where('device_name', 'admin')->find(); if ($device['device_status'] == 1) { $ws->to($device['device_fd'])->emit('add_callback', '刷新页面'); } } } } } ``` ###这里报错了 [think\exception\ErrorException] ```php Undefined offset: 1 Exception trace: () at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:493 think\initializer\Error->appError() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:493 think\db\Builder->parseWhereItem() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:386 think\db\Builder->parseWhereLogic() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:331 think\db\Builder->buildWhere() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/Builder.php:299 think\db\Builder->parseWhere() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/builder/Mysql.php:94 think\db\builder\Mysql->select() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/PDOConnection.php:916 think\db\PDOConnection->think\db\{closure}() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/PDOConnection.php:699 think\db\PDOConnection->pdoQuery() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/PDOConnection.php:917 think\db\PDOConnection->select() at /www/wwwroot/tp/vendor/topthink/think-orm/src/db/BaseQuery.php:1090 think\db\BaseQuery->select() at /www/wwwroot/tp/app/listener/WsTest.php:56 app\listener\WsTest->handle() at n/a:n/a ReflectionMethod->invokeArgs() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:328 think\Container->invokeMethod() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:361 think\Container->invoke() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Event.php:260 think\Event->dispatch() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Event.php:221 think\Event->trigger() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/concerns/InteractsWithWebsocket.php:91 think\swoole\Manager->think\swoole\concerns\{closure}() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:293 think\Container->invokeFunction() at /www/wwwroot/tp/vendor/topthink/framework/src/think/Container.php:357 think\Container->invoke() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/Sandbox.php:84 think\swoole\Sandbox->run() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/concerns/WithApplication.php:112 think\swoole\Manager->runInSandbox() at /www/wwwroot/tp/vendor/topthink/think-swoole/src/concerns/InteractsWithWebsocket.php:94 ```
赞
0
分享
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
评论
2021-07-01
鲁飞
这需要你自己调试了...
赞
0
回复
微信公众号
热门内容
作者其它话题
- 别人的终端启动Swoole之后还继续运行,我的启动之后就结束了,请哪位大神帮我解答一下吧,
暂无回复的问答
- CodeGalaxy K3s 轻量集群节点之间如何实现负载均衡
- 关于openssl CURL WARNING swSSL_connect: SSL_connect(fd=69) failed. Error: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small[1|394]
- 多个模型如何进行事务异常回退?
- websocket开启wss报错
- 协程tcp服务器如何使用多进程?recv()方法接收信息,打印出来的pid一直是同一个。没用使用到多进程啊。