从模型到控制器并返回到模型的数据
16lz
2021-01-22
<?php //controller
function notif()
{
$condition = $this->business_model->get_condition();
$this->data['query'] = $this->business_model->data_pagination_admin($condition);
$this->load->view('student_result',$this->data);
}
?>
<?php //model
function get_condition()
{
$this->db->select('condition');
$this->db->from('staff');
$query = $this->db->get();
return $query->result_array();
}
function data_pagination_admin($condition)//notif function
{
//...........
$this->db->where('flag','n');
//$user_id = $this->session->userdata('condition');
$this->db->where($condition,$user);//notice parameter condition
$this->db->order_by('next_date','asc');
$query = $this->db->get('student',10,0);
return $query->result_array();
}
/*im getting error :"Unknown column '0' in 'where clause'
SELECT * FROM (`student`) JOIN `status_table` ON `student`.`stud_id` =
`status_table`.`stud_id` WHERE `status_table`.`next_date` > '2013-06-09 23:59:59'
AND `flag` = 'n' AND **`0` = Array ORDER** BY `next_date` asc LIMIT 10"*/
?>
1.im geting value from model to controller and passing it to controller to another function but getting error.
1.从模型到控制器的最小值,并将其传递给控制器到另一个函数但是出错。
2.controller->get_condition->controller->data_pagination_admin()
3.the get condition function will return just a string thats all
3. get条件函数将返回一个全部字符串
2 个解决方案
#1
0
get_condition
currently returns an array; try the code below:
get_conditioncurrently返回一个数组;试试下面的代码:
function get_condition()
{
$user = $this->session->userdata('user_id');
$this->db->select('condition');
$this->db->from('staff');
$this->db->where('user_id',$user );
$query = $this->db->get();
$result = $query->row_array();
return $result['condition'];
}
Edit: looks like your $user var in that where clause is also an array.
编辑:看起来像$ user var,其中where子句也是一个数组。
更多相关文章
- MySQL按数组值排序
- 向数组添加一组数据库列的问题
- 如何使用webrequest使用Json数组绘制折线图
- javascript判断数组和对象中是否存在某元素
- [JavaScript] 将字符串数组转化为整型数组
- 将JSON ID键插入到ng-click指令中,然后将其传递到另一个控制器
- 数组中的值由于未知原因而更改
- javascript 动态数组的使用
- 如何从控制器内的javascript函数调用角范围函数