[英]Join get 4 tables all result by id
Now I am doing edit form in codeigniter and I want to get all four tables data. 现在,我在codeigniter中执行编辑表单,我想获取所有四个表数据。 From controller comes event_id and by this id I want to get data.
来自控制器的是event_id,我想通过该ID获取数据。
public function get_list_for_edit($event_id){
return
$this->db->select('*')
->from('events e')
->join('events_location el','el.events_id =' $event_id,'left')
->join('events_photos ep',
'ep.events_id =' $event_id,'left')
->join('push_notifications pn',
'pn.events_id =' $event_id,'left')
->where('e.event_id =' $event_id)
->row_object();
}
Message: syntax error, unexpected '$event_id' (T_VARIABLE) 消息:语法错误,意外的“ $ event_id”(T_VARIABLE)
could be you need string concatenation (othewise the variable in not correctly added to the rest of the string) 可能是您需要字符串连接(否则变量未正确添加到字符串的其余部分)
public function get_list_for_edit($event_id){
return
$this->db->select('*')
->from('events e')
->join('events_location el','el.events_id =' . $event_id,'left')
->join('events_photos ep',
'ep.events_id =' . $event_id,'left')
->join('push_notifications pn',
'pn.events_id ='. $event_id,'left')
->where('e.event_id =' . $event_id)
->row_object();
}
for Call to undefined method CI_DB_mysqli_driver::row_object() error 对于未定义方法CI_DB_mysqli_driver :: row_object()的调用错误
You are not selecting table name ... so you should add the get('TABLE_NAME') method for the table/model you need 您没有选择表名...因此应为所需的表/模型添加get('TABLE_NAME')方法
$this->db->select('*')
->from('events e')
->join('events_location el','el.events_id =' . $event_id,'left')
->join('events_photos ep',
'ep.events_id =' . $event_id,'left')
->join('push_notifications pn',
'pn.events_id ='. $event_id,'left')
->where('e.event_id =' . $event_id)->get('TABLE_NAME')
->row_object();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.