Welcome Guest, Not a member yet? Register   Sign In
Need help related to my codeigniter wallpaper script
#12

(01-12-2018, 05:02 AM)jreklund Wrote:
(01-12-2018, 04:02 AM)InsiteFX Wrote: GROUP BY should be the last statement in database queries.
It's the last statement. Take note of the brackets.

Thanks guys for your support, but didn't work.

I added

PHP Code:
public function color_sql($filter)
{
 
  $this->db->select('*, sum(count) AS color_sum');
 
  $this->db->from('wallpapers_colors');
 
  $this->db->where('saturation BETWEEN ' . (($filter['saturation'][0]) / 100) . ' AND ' . (($filter['saturation'][1]) / 100));
 
  $this->db->where('lightness BETWEEN ' . (($filter['lightness'][0]) / 100) . ' AND ' . (($filter['lightness'][1]) / 100));
 
  $this->db->where('hue BETWEEN ' . ($filter['hue'][0]) . ' AND ' . ($filter['hue'][1]));
 
  $this->db->group_by('wallpaper_seq_id');
 
  return $this->sql();
var_dump($filter);
die();



and returns I guess the same error:

Code:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BETWEEN0 AND 0.4 AND `lightness` BETWEEN 0.55 AND 0.95 AND `hue` BETWEEN0 AND 20' at line 4

SELECT COUNT(*) AS `numrows` FROM ((SELECT *, sum(count) AS color_sum FROM `WS_wallpapers_colors` WHERE `saturation` BETWEEN0 AND 0.4 AND `lightness` BETWEEN 0.55 AND 0.95 AND `hue` BETWEEN0 AND 20 GROUP BY `wallpaper_seq_id`) wc) JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wc`.`wallpaper_seq_id` LEFT JOIN (SELECT `t2`.*, GROUP_CONCAT(c.category_slug order by c1.lvl desc SEPARATOR '/') AS cFullSlug, GROUP_CONCAT(c.category_name order by c1.lvl desc SEPARATOR '|') AS cFullName FROM `WS_closures` `c1` LEFT JOIN `WS_category` `c` ON `c`.`category_seq_id` = `c1`.`ancestor` LEFT JOIN `WS_category` `t2` ON `t2`.`category_seq_id` = `c1`.`descendant` GROUP BY `c1`.`descendant`) as c ON `c`.`category_seq_id` = `w`.`category_seq_id` WHERE `w`.`wallpaper_status` = 1 AND `w`.`wallpaper_approved` = 1

Filename: core/WS_Model.php

Line Number: 76


But, also wonder why the 1st color that not returns the error, why not return the wallpaper? (Why is coding so hard? Kidding! Smile )
Reply


Messages In This Thread
RE: Need help related to my codeigniter wallpaper script - by stand - 01-12-2018, 10:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB