【发布时间】:2017-12-05 00:44:50
【问题描述】:
我有一个案例,这个案例真的让我很困惑,因为我尝试了很多解决方案,但我仍然没有从我的模型中得到我的 ID。
这是我的情况:
在我的模型上,我从数据库中收集了一些数据
然后我将它传递给我的控制器
当然,这些数据将是一个数组(对吗?)
然后在我的控制器上,我只想获取我的 ID 用于其他目的(我将再次将它传递给我的模型,只有我的 ID)
但我对如何在控制器上提取数据感到困惑
这里按照我的方法使用我的$data['query'] 获取 ID:
$data['query'] = $this->mkomentar->get_all_($params);
$id = $data['query'];
$id_new = $id->hits->hits->_source->id;
下面是我的var_dump $id_new:
下面是我的var_dump $data['query']:
object(stdClass)#17 (4) { ["took"]=> int(4) ["timed_out"]=> bool(false) ["_shards"]=> object(stdClass)#18 (3) { ["total"]=> int(5) ["successful"]=> int(5) ["failed"]=> int(0) } ["hits"]=> object(stdClass)#19 (3) { ["total"]=> int(1) ["max_score"]=> float(1.6931472) ["hits"]=> array(1) { [0]=> object(stdClass)#20 (5) { ["_index"]=> string(11) "tryelastic2" ["_type"]=> string(11) "tryelastic2" ["_id"]=> string(20) "AVz4fiU3Gx0i_9jPP49l" ["_score"]=> float(1.6931472) ["_source"]=> object(stdClass)#21 (6) { ["id"]=> int(2) ["nama"]=> string(7) "Jhordan" ["url"]=> string(11) "jhordan.com" ["pesan"]=> string(5) "aiueo" ["code"]=> string(3) "247" ["status"]=> int(2) } } } } }
【问题讨论】:
-
用您的代码而不是您的代码图像更新您的问题。 meta.stackexchange.com/questions/22186/…
-
好的,对不起,已经修复了@wolfgang1983
-
用你的模型函数更新问题是这个,还有
$id->hits->hits->_source->id;是一个库函数还是另一个模型函数? -
我的模型代码是查询 elasticsearch 先生 @wolfgang1983 的函数
-
使用查询添加您的型号代码
标签: php mysql codeigniter elasticsearch