Php 代码点火器中的交叉连接?
我在试这个Php 代码点火器中的交叉连接?,php,codeigniter,activerecord,Php,Codeigniter,Activerecord,我在试这个 $this->db->join('tableTwo as b','','CROSS'); $result = $this->db->get('tableOne as a')->result(); 一些解决方案?在codeigniter中交叉连接的解决方案: $this->db->join('tableTwo as b','true'); $result = $this->db->get('tableOne as a')->
$this->db->join('tableTwo as b','','CROSS');
$result = $this->db->get('tableOne as a')->result();
一些解决方案?在codeigniter中交叉连接的解决方案:
$this->db->join('tableTwo as b','true');
$result = $this->db->get('tableOne as a')->result();
您应该这样使用它:
$this->db->join('tableTwo as b','true');
$result = $this->db->get('tableOne as a')->result();
在codeigniter 3中,您可以通过以下方式添加交叉连接查询生成器
或者通过从方法或get方法传入数组
或
或者通过在from中传递一个表,在get方法中传递另一个表
$result = $this->db->from('tableOne as a')
get('tableTwo as b')->result();
对于前来查看Codeigniter 4的答案的人:
//tableOne is defined in the model
$this->model->join('tableTwo', 'column_x= column_y', 'cross');
第一个参数是表名,下一个参数是联接的条件,第三个参数是联接的类型
因此,如果您有这样一个SQL语句:
cross join producto_resumen_color on prre_id = prco_prre_id
你应该这样做:
->join('producto_resumen_color','prre_id = prco_prre_id', 'cross')
您可以在CI的用户指南中找到更多信息
连接选项有:左、右、外、内、左外和右外。
//tableOne is defined in the model
$this->model->join('tableTwo', 'column_x= column_y', 'cross');
cross join producto_resumen_color on prre_id = prco_prre_id
->join('producto_resumen_color','prre_id = prco_prre_id', 'cross')
join($table, $cond[, $type = ''[, $escape = NULL]])
Parameters:
$table (string) – Table name to join
$cond (string) – The JOIN ON condition
$type (string) – The JOIN type
$escape (bool) – Whether to escape values and identifiers