$user
包含数据库中的CHAR
数据类型。
我的错误是:
消息:无法将类CI_DB_oci8_result的对象转换为 串
这是我的代码:
$this->db->select('CONSULTATION_DATE,CONSULTATION_DESC,CONSULTATION_STATUS');
$this->db->from('SCHEDULE_REQUEST');
$this->db->where("STUDENT_ID= '". $user."'");
$this->db->where("CONSULTATION_STATUS LIKE 'Accept'");
$data['status']=$this->db->get();
答案 0 :(得分:0)
使用此
$this->db->select('CONSULTATION_DATE,CONSULTATION_DESC,CONSULTATION_STATUS');
$this->db->from('SCHEDULE_REQUEST');
$this->db->where("STUDENT_ID= '". $user."'");
$this->db->where("CONSULTATION_STATUS LIKE 'Accept'");
$result=$this->db->get();//data store as Object Array
编辑01
$this->db->select('CONSULTATION_DATE,CONSULTATION_DESC,CONSULTATION_STATUS');
$this->db->from('SCHEDULE_REQUEST');
$this->db->where("STUDENT_ID= '". $user."'");
$this->db->where("CONSULTATION_STATUS LIKE 'Accept'");
$result=$this->db->get();//data store as Object Array
$data['array'] = $result;
在视图中
foreach ( $array as $item )
{
echo $item['table_filed'];
}
编辑02
在模型中
public function get_data($user)
{
$query = $this->db->query("SELECT CONSULTATION_DATE,CONSULTATION_DESC,CONSULTATION_STATUS FROM schedule_request WHERE STUDENT_ID= '$user' AND CONSULTATION_STATUS LIKE 'Accept' ");
$result = $query->result_array();
return $result;
}
在控制器
中$data['result'] = $this->Model_name->get_data($user);
$this->load->view("View_name",$data)
在视图中
foreach ($result as $item )
{
echo $item['table_filed'];
}