БД Codeigniter date_formatPhp

Кемеровские программисты php общаются здесь
Anonymous
БД Codeigniter date_format

Сообщение Anonymous »

Я использую CodeIgniter и сделал такой запрос.

Код: Выделить всё

$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');
и получите этот результат в формате CSV:

Код: Выделить всё

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);
Я пытаюсь отформатировать дату платежа в формате «д/м/Г», но DATE_FORMAT выдает ошибки:

Код: Выделить всё

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
Что я могу сделать, чтобы это исправить?

Вернуться в «Php»