#0 [2]ErrorException in Article.php line 224

Invalid argument supplied for foreach()

  1. $contentTemplateInfo = DB::name('DataTemplate')->where(["id" => $articleCate['content_template_id']])->find(); //内容模板信息
  2. if (!$contentTemplateInfo['table_name']) {
  3. return $this->fetch("error_page");
  4. exit;
  5. }
  6. //获得当前图文信息
  7. $article = Db::name($contentTemplateInfo['table_name'])->where('id', $id)->find();
  8. foreach ($article as $k => $v) {
  9. if (!empty($v) && strpos($v, "|") !== false && !in_array($k, ['title', 'subtitle', 'content', 'keywords'])) {
  10. //处理字段内是否有“|”符号,如果有则拆分成数组
  11. $article[$k] = explode("|", $v);
  12. }
  13. }
  14. if (!empty($article['associated'])) {
  15. $associated = json_decode($article['associated'], true);
  16. $article['associatedList'] = Db::name($associated['tableName'])
  17. ->where('id', 'IN', $associated['id'])->order('sort desc,id desc')

Call Stack

  1. in Article.php line 224
  2. at Error->appError(2, 'Invalid argument sup...', '/www/wwwroot/sewhome...', 224, ['id' => '48', 'catId' => '38', 'articleCate' => ['id' => 38, 'parent_id' => 29, 'title' => '电子自动型', ...], ...]) in Article.php line 224
  3. at Article->show()
  4. at ReflectionMethod->invokeArgs(object(Article), []) in Container.php line 344
  5. at Container->invokeReflectMethod(object(Article), object(ReflectionMethod), ['cat_id' => '38', 'id' => '48']) in Controller.php line 110
  6. at Controller->think\route\dispatch\{closure}(object(Request)) in Pipeline.php line 59
  7. at Pipeline->think\{closure}(object(Request)) in Pipeline.php line 66
  8. at Pipeline->then(object(Closure)) in Controller.php line 113
  9. at Controller->exec() in Dispatch.php line 90
  10. at Dispatch->run() in Route.php line 772
  11. at Route->think\{closure}(object(Request)) in Pipeline.php line 59
  12. at Pipeline->think\{closure}(object(Request)) in Library.php line 139
  13. at Library->think\admin\{closure}(object(Request), object(Closure))
  14. at call_user_func(object(Closure), object(Request), object(Closure)) in Middleware.php line 142
  15. at Middleware->think\{closure}(object(Request), object(Closure)) in Pipeline.php line 85
  16. at Pipeline->think\{closure}(object(Request)) in Pipeline.php line 66
  17. at Pipeline->then(object(Closure)) in Route.php line 773
  18. at Route->dispatch(object(Request), object(Closure)) in Http.php line 216
  19. at Http->dispatchToRoute(object(Request)) in Http.php line 206
  20. at Http->think\{closure}(object(Request)) in Pipeline.php line 59
  21. at Pipeline->think\{closure}(object(Request)) in Multiple.php line 72
  22. at Multiple->think\admin\multiple\{closure}(object(Request)) in Pipeline.php line 59
  23. at Pipeline->think\{closure}(object(Request)) in Pipeline.php line 66
  24. at Pipeline->then(object(Closure)) in Multiple.php line 73
  25. at Multiple->handle(object(Request), object(Closure))
  26. at call_user_func([object(Multiple), 'handle'], object(Request), object(Closure)) in Middleware.php line 142
  27. at Middleware->think\{closure}(object(Request), object(Closure)) in Pipeline.php line 85
  28. at Pipeline->think\{closure}(object(Request)) in LoadLangPack.php line 57
  29. at LoadLangPack->handle(object(Request), object(Closure))
  30. at call_user_func([object(LoadLangPack), 'handle'], object(Request), object(Closure)) in Middleware.php line 142
  31. at Middleware->think\{closure}(object(Request), object(Closure)) in Pipeline.php line 85
  32. at Pipeline->think\{closure}(object(Request)) in SessionInit.php line 67
  33. at SessionInit->handle(object(Request), object(Closure))
  34. at call_user_func([object(SessionInit), 'handle'], object(Request), object(Closure)) in Middleware.php line 142
  35. at Middleware->think\{closure}(object(Request), object(Closure)) in Pipeline.php line 85
  36. at Pipeline->think\{closure}(object(Request)) in Pipeline.php line 66
  37. at Pipeline->then(object(Closure)) in Http.php line 207
  38. at Http->runWithRequest(object(Request)) in Http.php line 170
  39. at Http->run() in SystemService.php line 484
  40. at SystemService->doInit() in index.php line 10

Environment Variables

GET Dataempty
POST Dataempty
Filesempty
Cookies
ssid e22fda272409d62d2a708fa0e335993e
lang zh-cn
PHPSESSID jpmeoqcbn1i0f7s6ce7ntg28d7
Session
lang cn
Server/Request Data
USER www
HOME /home/www
HTTP_COOKIE ssid=e22fda272409d62d2a708fa0e335993e; lang=zh-cn; PHPSESSID=jpmeoqcbn1i0f7s6ce7ntg28d7
HTTP_ACCEPT_ENCODING gzip
HTTP_ACCEPT */*
HTTP_HOST www.sewhome.com
HTTP_USER_AGENT Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.108 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
PATH_INFO
REDIRECT_STATUS 200
SERVER_NAME sewhome.com
SERVER_PORT 80
SERVER_ADDR 172.26.35.20
REMOTE_PORT 46462
REMOTE_ADDR 170.130.206.126
SERVER_SOFTWARE nginx/1.22.1
GATEWAY_INTERFACE CGI/1.1
REQUEST_SCHEME http
SERVER_PROTOCOL HTTP/1.1
DOCUMENT_ROOT /www/wwwroot/sewhome.com
DOCUMENT_URI /index.php
REQUEST_URI /index/Article/show/cat_id/38/id/48
SCRIPT_NAME /index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHOD GET
QUERY_STRING s=/index/Article/show/cat_id/38/id/48
SCRIPT_FILENAME /www/wwwroot/sewhome.com/index.php
FCGI_ROLE RESPONDER
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1733535688.6454
REQUEST_TIME 1733535688
Baidu
sogou