简体   繁体   中英

Codeigniter MSSQL query error but fine in SQL Studio

Im using Codeigniter with MSSQL Database and having issues with queries, Im using the active record class in the following way

$this->db->protect_identifiers('content');
$this->db->protect_identifiers('url');
$this->db->select('url.url AS url, content.title AS title, content.id AS id');
$this->db->from('content');
$this->db->where('content.parent',$parent);
$this->db->where('content.menu',1);
$this->db->where('content.live',1);
$this->db->where('url."default"',1);
$this->db->join('url', 'content.id = url.content_id');
$this->db->order_by('content."order"','ASC');

Which is building the following query and causing an error

SELECT url.url AS url, content.title AS title, content.id AS id FROM content JOIN url ON    content.id = url.content_id WHERE content.parent = 0 AND content.menu = 1 AND content.live = 1 AND url."default" = 1 ORDER BY content."order" ASC

If i run the same query through SQL Studio it executes fine

Any ideas whats going wrong?

You have a field named "ORDER". Do not name fields in SQL Server that are reserved words.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM