Error Number: 1064 You have an error in your SQL syntax; check the manual that corre
function getRandomProducts($limit, $skip) {
$data = array();
$temp = array();
if ($limit == 0) {
$limit = 3;
}
$this->db->select("id ,name ,thumbnail ,category_id");
$this->db->where('id !=', $skip);
$this->db->where('status', 'active');
$this->db->order_by("category_id", "asc");
$this->db->limit(100);
$Q = $this->db->get('products');
if ($Q->num_rows() > 0) {
foreach ($Q->result_array() as $row) {
$temp[$row['category_id']] = array(
"id" => $row['id'],
"name" => $row['name'],
"thumbnail" => $row['thumbnail']
);
}
}
shuffle($temp);
if (count($temp)) {
for ($i = 1; $i <= $limit; $i++) {
$data[] = array_shift($temp);
}
}
$Q->free_result();
return $data;
}
|