Danny620 Posted January 23, 2014 Share Posted January 23, 2014 This is my code $this->db->select("b.id, p.name, CONCAT_WS(' ', u.first_name, u.last_name ) AS full_name, DATE_FORMAT(b.check_in, '%d %b %Y') AS ck_in, DATE_FORMAT(b.check_out, '%d, %b %Y') AS ck_out, b.canceled, DATE_FORMAT(b.booked_on, '%d, %b %Y') AS booked_on"); $this->db->from('bookings b'); $this->db->join('pubs p', 'b.pub_id = p.id'); $this->db->join('users u', 'b.customer_id = u.id'); $this->db->where('b.user_id', $user_id); return $this->db->get()->result_array(); when i run i get Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%d`, `%b` %Y') AS ck_out, `b`.`canceled`, DATE_FORMAT(b.booked_on, `'%d`, `%b` %' at line 1 SELECT `b`.`id`, `p`.`name`, CONCAT_WS(' ', `u`.`first_name`, `u`.`last_name` ) AS full_name, DATE_FORMAT(b.check_in, `'%d` %b %Y') AS ck_in, DATE_FORMAT(b.check_out, `'%d`, `%b` %Y') AS ck_out, `b`.`canceled`, DATE_FORMAT(b.booked_on, `'%d`, `%b` %Y') AS booked_on FROM (`bookings` b) JOIN `pubs` p ON `b`.`pub_id` = `p`.`id` JOIN `users` u ON `b`.`customer_id` = `u`.`id` WHERE `b`.`user_id` = '3' Quote Link to comment https://forums.phpfreaks.com/topic/285617-codeigniter-active-record/ Share on other sites More sharing options...
Barand Posted January 23, 2014 Share Posted January 23, 2014 the error message is showing backticks in the DATE_FORMAT() parameters right syntax to use near '%d`, `%b` %Y') Quote Link to comment https://forums.phpfreaks.com/topic/285617-codeigniter-active-record/#findComment-1466300 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.