Jump to content

Codeigniter Active Record


Danny620

Recommended Posts

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'
Link to comment
https://forums.phpfreaks.com/topic/285617-codeigniter-active-record/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.