Codeigniter DB date_format
I am using CodeIgniter and I made a query like this.
$this->db->select("first_name as 'First Name', last_name as 'Last Name',
phone as 'Phone', os.group as 'Group', gender as 'Gender', birth_date as
'DOB', email as 'Email', street_address as 'Address', city as 'City',
province as 'Province', postal_code as 'Postal Code', country 'Country',
payment_amount as 'Payment Amount', DATE_FORMAT(payment_date, '%d/%m/%Y')
as 'Payment Date', an.notes as 'Notes'");
$this->db->join('athlete_notes an', 'os.id = an.id',
'inner');
$this->db->group_by(array("first_name", "last_name"));
$this->db->order_by("last_name asc, first_name asc");
$query = $this->db->get('offline_shoppers os');
and get this csv output:
header("Content-type: text/csv");
header("Content-Disposition: attachment;
filename=members_list.csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $this->dbutil->csv_from_result($query);
I am trying to format the payment_date to d/m/Y but DATE_FORMAT gave me
errors:
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 'FROM
(`offline_shoppers` os) INNER JOIN `athlete_notes` an ON `os`.`id` =
`an`.`' at line 2
What can I do to fix this?
No comments:
Post a Comment