如何在屏幕上的 CI 查询中回显多个 where 子句

How to echo multiple where clauses in a CI query on screen

我正在尝试获取数据库的结果 table 并回应查询结果。 这是我的代码:

$queryDB = $this->db->select('*')
                ->from('dr_template_relational')
                ->where('value_id', $categoryDetails['value_id'])
                ->where('subcategory_id', $categoryDetails['subcategory_id'])
                ->get();
echo "<br>";
echo "here is queryDB";
echo($queryDB);
echo "that was it";

                

$queryDB 没有回显,所以我确定数据在那里。我想知道我做错了什么。我没有收到错误,但也没有在屏幕上显示 echo($queryDB); 的任何输出:

here is queryDBthat was it

现在,您的方法只是回显查询实例。

为了查看查询结果,您需要创建它们。有几个 CI 函数,例如 result()row()

最后可能是这样的:

foreach ($queryDB ->result() as $row){
        echo $row->value_id;
        echo $row->subcategory_id;
}

Generating Query Results

提示:要查看生成的查询,您可以使用

echo $this->$db->last_query();