在library/comment.php上的链接
function getSelectedOneFieldJoin2TblGroupOrder($select, $table, $where, $join_table1, $join_condition1, $join_table2, $join_condition2, $order_by=null)
{
$this->CI->db->select($select);
$this->CI->db->from($table);
$where2 = substr($where,6);
$this->CI->db->where($where2);
$this->CI->db->join($join_table1, $join_condition1, 'left');
$this->CI->db->join($join_table2, $join_condition2, 'left');
$this->CI->db->order_by($order_by);
$query = $this->CI->db->get();
$result = $query->row_array();
if ($result) {
return $result[$select];
}
return null;
}
字符串
在控制器/ Jmeter 板. php上
$res1=$this->common->getSelectedOneFieldJoin2TblGroupOrder(
" 'Product Order Placed' as activity_title, u.created_on as created_on, m.first_name AS created_by",
"tbl_product_order u",
"WHERE u.status != 2 and u.status != 0",
"tbl_package_master p", // $join_table1
"p.id = u.package_id",
"tbl_user_master m", // $join_table2
"m.user_id = u.user_id",
"u.created_on", "ASC"
);
型
在view/dashboard.php上查看
foreach($form_data as $Res)
{
echo $Res['activity_title'] . " :: ";
echo $Res['created_on'];
}
型
显示空结果。
当我把return**$result[$select];改为return $result;**时,它会显示3个结果,但在数组索引中没有值...
如何正确显示结果?
1条答案
按热度按时间yshpjwxd1#
$query->row_array()
只返回结果集的第一行,作为一个数组,以您在SELECT
中指定的字段作为其键。我无法从你的问题中判断出你是想只显示结果集中的第一行还是所有行,所以:
$query->row_array()
改为$query->result_array()
,并在视图中保持foreach
循环。$query->row_array()
),并从视图中删除foreach
循环,只保留echo
语句:字符串