我需要查询数据库并为列返回不同的值。查询在 foreach 循环中,并根据数组而变化。
$get_all_col_names = $this->db->list_fields($table_by_product);
//This will return "X_SIZE", "X_PRINT", "X_QTY"
现在我有一个 foreach 需要分别获取“X_SIZE”、“X_PRINT”和“X_QTY”的不同值。
foreach ($X_types as $X) {
$this->db->select($X);
$this->db->distinct();
$qX = $this->db->get($table_by_product);
return $qX->result_object();
}
当前设置的问题在于它只返回 X_QTY 的 DISTINCT 值,这是列表中的最后一个数组。
我需要为数组中的所有键返回不同的值。我怎样才能使这项工作?谢谢您的帮助。