首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
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 ```
发布于5年前 · 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
回复