phpdragon 发表于 2015-3-27 13:47:01

$this->db->join() 不支持AND条件问题,以后的条件不加表前缀BUG..

$this->db->join('product', 'product.productID = order_info.productID AND product.brandID = order_info.brandID','left');
不支持上面的调用方法。

改造:
class CI_DB_active_record extends CI_DB_driver{

//330行
// Strip apart the condition and protect the identifiers                if(is_array($cond)){
                  $cond_arr = $cond;
                  $cond = array();
                  foreach($cond_arr as $value){
                            if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $value, $match))
                            {
                                    $match = $this->_protect_identifiers($match);
                                    $match = $this->_protect_identifiers($match);


                                    $cond[] = $match.$match.$match;
   
                            }
                  }
                  $cond = implode(' AND ', $cond);
                }else{
                     if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
                            {
                                    $match = $this->_protect_identifiers($match);
                                    $match = $this->_protect_identifiers($match);


                                    $cond = $match.$match.$match;
                            }
                }



结果:
$this->db->join('product', array('product.productID = order_info.productID','product.brandID = order_info.brandID'),'left');




大家是否觉得有必要加入该特性,或者解决 AND 以后的条件不加 表前缀的BUG。
页: [1]
查看完整版本: $this->db->join() 不支持AND条件问题,以后的条件不加表前缀BUG..