Codeigniter和Firebird $ this-> db->加入较低的支持

时间:2017-07-17 06:00:45

标签: php codeigniter join firebird

我正在使用Codeigniter从Firebird数据库获取记录:

$columns = [
            'job.JOBID AS Id', 'job.ORDERID AS orderID', 'suburb.LONGITUDE AS Longitude', 'suburb.LATITUDE AS Latitude', 'suburb.LCNAME', 'address.TOWN', ];
        $this->db->select($columns);
        $this->db->from('WORK as job');
        $this->db->join('CUSTOMER AS customer', 'customer.CUSTOMERID = job.CUSOMERTID', 'INNER');
        $this->db->join('SALEORDER AS sorder', 'sorder.ORDERID = job.ORDERID', 'INNER');
        $this->db->join('CUSTADDRESS AS address', 'address.ADDRID = sorder.DELADDRID', 'INNER');        
        $this->db->join('WORK2 AS job2', 'job2.JOBID = job.JOBID', 'LEFT');

        // THE BELOW LINE CAUSE ERROR DUE TO LOWER
        $this->db->join('SUBURBS AS suburb', 'suburb.LCNAME = LOWER(address.TOWN)', 'LEFT');

        $query = $this->db->get();

代码在没有LOWER的情况下正常运行,相关的JOIN在没有它的情况下无效,因为条件为false。我已经说过,suburb.LCNAME = 'blacktown'address.Town = BlackTown

我收到以下错误消息,

  

遇到PHP错误   严重性:警告
  消息:ibase_query():动态SQL错误SQL错误代码= -206列未知ADDRESS.TOWN在第12行第1列   文件名:ibase / ibase_driver.php
  行号:129

2 个答案:

答案 0 :(得分:1)

删除别名地址并使用以下行中的原始表名以及代码。 $ this-> db-> join(' CUSTADDRESS AS地址',' address.ADDRID = sorder.DELADDRID',' INNER');

使用相反: $ this-> db-> join(' CUSTADDRESS',' CUSTADDRESS.ADDRID = sorder.DELADDRID',' INNER');

答案 1 :(得分:0)

试试这个

$this->db->select($columns.',LOWER(address.Town) as lower_address');
 $this->db->from('WORK as job');
 $this->db->join('CUSTOMER AS customer', 'customer.CUSTOMERID = job.CUSOMERTID', 'INNER');
 $this->db->join('SALERDER AS sorder', 'sorder.ORDERID = job.ORDERID', 'INNER');
 $this->db->join('CUSTADDRESS AS address', 'address.ADDRID = sorder.DELADDRID', 'INNER');        
 $this->db->join('WORK2 AS job2', 'job2.JOBID = job.JOBID', 'LEFT');

 // THE BELOW LINE CAUSE ERROR DUE TO LOWER
 $this->db->join('SUBURBS AS suburb', 'suburb.LCNAME = lower_address', 'LEFT');

 $query = $this->db->get();