- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
<分区>
我已经尝试了几种不同的方法来解决这个问题,但到目前为止还没有解决方案。我收到此错误消息:
“where 子句”中的未知列“Array”
SELECT * FROM (Articles
) WHERE id
IN (数组,数组,数组,数组,数组,数组,数组,数组,数组,数组,数组,数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组, 数组)
这是我的模型代码:
function getStarNews($user_id) {
$this->db->select('id');
$this->db->where('user_id', $user_id);
$query = $this->db->get('table1');
foreach ($query->result_array() as $id)
{
//echo $id['id']."<br>"; //displays all of the correct ids I am trying to pass to the where_in()
}
$id = $query->result_array();
$this->db->where_in('id', $id); //pass array of 'id' from above query
$data = $this->db->get('Articles');
return $data->result_array();
}
如果我将 id 数组更改为仅包含 1 个值,则 where_in() 子句可以正常工作并输出与单个“id”匹配的数据行。
我在整个堆栈和谷歌上寻找有关使用 where_in() 的帮助,我认为我的一切都是正确的,或者已经尝试了几种不同的方法来正确传递数组。
感谢您的帮助。
编辑:最后我将使用我的 Controller 输出这些数据:
$this->output->set_output(json_encode($data));
出于测试目的,我只是跳过 JSON 并尝试使用 PHP 直接从模型输出数据。
我正在使用 codeigniter 查询数据库,我需要在 where 子句中有条件地比较数组。 所以基本上我想做的是:where_in 或 where_in 取决于哪个数组中有数据。所以我将拥有一个
CodeIgniter where_in 查询只处理第一个值。数据库字段类型是 varchar(255)。使用 where_in 仅适用于第一个选项 - 就像如果值为 1,2 那么查询适用于 1 和
我想显示一些特定字段和特定 ID 的结果,但我不知道该怎么做。 下面的代码是我的实验,但它显示了所有结果(不基于 id) $this->db->where_in('id',$id); $query =
我正在尝试选择 id 并通过使用它将其传递给更新 $query = $this->db->query("SELECT GROUP_CONCAT(a.sponsor_id) as sponstr FRO
我想限制每个 id 的结果(数组 id 只有 3 个结果)。 如果我添加: $this->db->limit(3); 我总共收到了三个记录;但我希望每个 ID 有 3 条记录。 我该怎么办? 1,
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我正在使用 Codeigniter 3 构建网站。但是现在我在从数据库中获取数据时遇到了问题。 这是我的模型: public function Get($arr_condition = null) {
我有两个疑问: $genres = $this->db->select('Group_Concat(intGenreId) strDJGenres')
我需要一个 Codeigniter 查询来从 JSON 列 MYSQL 表中获取结果。 示例列数据如下。 ["1","2","6","4","3","5","7","9","8"] 目前我正在为此使用
我有这个代码: 模型(Mproses.php): function cari($d,$p) { $this->db->select('cf_pakar,gejala');
这个问题已经有答案了: Codeigniter model with multiple update conditions using manual where statement (1 个回答) 已
我正在处理一个连接查询,我必须从包含逗号分隔值的列中获取数据。比如 allowed_activity包含 1,2,3,4,5,6这activity_id这是允许的。 所以在查询中,我正在检查是否允许当
我希望执行以下操作(请参阅伪代码);我想为每个 gd.id(7、11 或 9)选择 4 行。我错误地使用了限制,因为它总共只显示了 4 行。任何人都知道如何更改此查询以实现我的目标? SELECT g
下面是codeigniter单列where_in子句$this->db->where_in('x1',$val); 我如何在 CodeIgniter where_in 子句中传递多个列,如下面的 My
我正在使用 Codeigniter 2。我正在尝试使用 Active Record 进行 mysql 查询。问题是当传递给 where_in 的数组为空时出现错误。我问如果数组为空,是否有任何方法可以
我有一个 MySQL 查询,可以在 PhpMyAdmin/MySQL Workbench 中使用。 SELECT * FROM (`medfacts`) JOIN `categories_med
以下是一个 VIEW search_result。 skills 列包含与其他表中的值GROUP_CONCAT 的值。 现在我正尝试使用像这样的 where_in 子句从此 View 中选择值: $s
我正在开发一个搜索功能。我创建了一个搜索表单,用户可以在其中搜索基于 Type、ope 和 Formate 的应用程序。 我在我的join 查询中使用了一个子查询 以获得所需的结果。我已经在 MySQ
我正在开发一个搜索功能。我创建了一个搜索表单,用户可以在其中搜索基于 Type、ope 和 Formate 的应用程序。 我在我的join 查询中使用了一个子查询 以获得所需的结果。我已经在 MySQ
我有一个可以正常运行的查询,但我不知道如何在 codeigniter 中编写 这是我的查询 SELECT id,contact,firstname,email FROM `user` WHERE `i
我是一名优秀的程序员,十分优秀!