我这里有这段代码
$sql_array = array();
if($result['user_id'] == 'OA'){
$sql = "select distinct id, FirstName, LastName from table_one ti left join table_two sp on (sp.user_id = ti.id) or (sp.user_id = ti.id)";
$query = $this->db->query($sql);
$results_array = $query->result_array();
$sql_array = array_push($sql_array, $results_array);
}
elseif($result['user_id'] == 'SH'){
$sql = "select distinct id, first_name, last_name from table_three teo left join table_two sp on sp.user_id = teo.id";
$query = $this->db->query($sql);
$results_array = $query->result_array();
$sql_array = array_push($sql_array, $results_array);
}elseif($result['user_id'] == 'OF'){
$sql = "select distinct id, first_name, last_name from table_four os left join table_two sp on sp.user_id = os.id";
$query = $this->db->query($sql);
$results_array = $query->result_array();
$sql_array = array_push($sql_array, $results_array);
}elseif($result['user_id'] == 'US'){
$sql = "select distinct ID, substring_index(display_name, ' ', 1) as 'FirstName', substring_index(display_name, ' ', -1) as 'LastName' from table_five tu left join table_two sp on sp.user_id = tu.id";
$query = $this->db->query($sql);
$results_array = $query->result_array();
$sql_array = array_push($sql_array, $results_array);
}
它遍历所有 $result['user_id'] 并查看要运行的查询字符串基于 $result['user_id'] 是什么......使用上面的代码我得到了一个错误array_push() expects parameter 1 to be array, integer given
我做错了什么还是有更好的方法来做到这一点?
谢谢,J