04-21-2015, 09:05 PM
при открытии страницы в моем магазине с купленными товарами
выдает ошибку
выдает ошибку
PHP код:
<?php
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 'AS work_price FROM works_sales AS s LEFT JOIN works AS w ON (s.work = ' at line 1
SELECT s.*, w.* AS work_price FROM works_sales AS s LEFT JOIN works AS w ON (s.work = w.id) WHERE s.user = 1 ORDER BY s.date DESC
Filename: /var/www/hoske/data/www/site.ru/models/work.php
Line Number: 188
сам запрос вот такого вида
PHP код:
<?php
public function get_purchased($id)
{
$sql = "SELECT s.*, w.* AS work_price FROM works_sales AS s
LEFT JOIN works AS w ON (s.work = w.id)
WHERE s.user = " . $id . "
ORDER BY s.date DESC";
$query = $this->db->query($sql);
$works = $query->result();
$result = array();
foreach($works as $work)
if(!empty($work->name))
$result[] = $work;
return $result;
}