Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.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
Fuel\Core\phperroreException[警告]:数组\u key\u exists():第一个参数应该是字符串或整数_Php_Fuelphp - Fatal编程技术网

Fuel\Core\phperroreException[警告]:数组\u key\u exists():第一个参数应该是字符串或整数

Fuel\Core\phperroreException[警告]:数组\u key\u exists():第一个参数应该是字符串或整数,php,fuelphp,Php,Fuelphp,输入类别id时,尝试获取要填充类别名称的下拉列表。不幸的是,我犯了一个错误。返回的SQL应该是键的整数和值的字符串。然而,警告说,事实并非如此。我已经检查了屏幕上的查询输出,以再次检查它是否确实是一个整数/字符串 视图:content.php <label for="category">Category</label> <form action="content.php" method="post"> <input type="<?php Inpu

输入类别id时,尝试获取要填充类别名称的下拉列表。不幸的是,我犯了一个错误。返回的SQL应该是键的整数和值的字符串。然而,警告说,事实并非如此。我已经检查了屏幕上的查询输出,以再次检查它是否确实是一个整数/字符串

视图:content.php

<label for="category">Category</label>
<form action="content.php" method="post">
<input type="<?php Input::post($data['id']) ?>" name="category" ><br />

<br />


<div class=" form-group">
<div class=" form-group">
<select class="form-control form-control-sm">
<?php
                                                            Input::get($data['id']);
foreach($data as $option){ ?>
<option><?= $option['name'] ?></option>
 <?php } ?> 
</select>
模型:shelf.php

class Controller_Shelf extends Controller
{
    public function action_index()
    {
        $model = new Model_Shelf();
        $data = $model->get_results();
        // create the layout view
        $view = View::forge('shelf/index');

        // assign global variables so all views have access to them
        /* $view->data = $result; */


        //assign views as variables, lazy rendering
        $view->head = View::forge('common/head');
        $view->header = View::forge('common/header');
        $view->content = View::forge('common/content', array('data'=>$data));
        $view->footer = View::forge('common/footer');

        // return the view object to the Request
        //return $view;
        return Response::forge($view);
    }

    public function post_index()
    {
        // This will be called when the HTTP method is POST.
    }

}
class Model_Shelf extends \Model 
{    
    public static function get_results()
    {
        /* $result = DB::query('select substring(cat.item_class_cd,1,1) as id, cat.class_name as name
        from MASTER_DB.MS_CATEGORY cat
        where length(cat.item_class_cd) = 1')->execute(); */
        // doesn't work
        $result = DB::query('select cast(cat.item_class_cd as decimal) as id, cat.class_name as name
        from MASTER_DB.MS_CATEGORY cat
        where length(cat.item_class_cd) = 1')->execute();

        return $result;
        //return ['id' => 1, 'name' => 'test']
    }
 } 
错误消息与标题相同

array_key_exists(): The first argument should be either a string or an integer
COREPATH/classes/arr.php @ line 57

52            return $return;
53        }
54
55        is_object($key) and $key = (string) $key;
56
57        if (array_key_exists($key, $array))
58        {
59            return $array[$key];
60        }
61
62        foreach (explode('.', $key) as $key_part)
我该如何解决这个问题?
谢谢你的帮助。如果您需要澄清,请告诉我。

尝试使用
var\u dump($key)
查看它实际包含的内容。(顺便说一句,我不喜欢第55行的代码,这不是一个制作易读代码的好方法)第55行的代码是FuelPHP核心代码的一部分,所以我没有编程。这就是错误显示中显示的内容。我不确定是否可以使用“var\u dump($key);”那里