Welcome Guest, Not a member yet? Register   Sign In
$this->db->having() Issue
#1

[eluser]daweb[/eluser]
Hi everybody,

I have an issue whit the func in object.

This is my query:

Code:
SELECT `products`.`cod`, `products`.`category_cod`, `products`.`extended_cod`, `products`.`extended_category_cod`, `products`.`title`, `products`.`seo_title`, `products`.`content`, `products`.`price`, `categories`.`title` as category_title, `categories`.`seo_title` as category_seo_title, `categories`.`extended_description` as description, `products`.`stock`, `products`.`language`, `products`.`status`, `special_prices`.`special_price` as special_price FROM (`products`) JOIN `categories` ON `products`.`category_cod` = `categories`.`cod` and products.language = categories.language LEFT JOIN `special_prices` ON `special_prices`.`product_cod` = `products`.`cod` and special_prices.status = 1 HAVING `products`.`language` = ITA AND `products`.`status` = 1 AND `products`.`stock` = 1 AND `products`.`category_cod` = 7 ORDER BY `products`.`order`

Unknown column 'ITA' in 'having clause'

How can I escape ITA?!!!?
#2

[eluser]dmorin[/eluser]
I don't have an escaping solution, but why are you using Having instead of where when you aren't doing any aggregate functions and don't have a group by statement?

Can you also post the php code you're using to generate this instead of just the resulting SQL?
#3

[eluser]daweb[/eluser]
'cos I have to make a group by...
#4

[eluser]dmorin[/eluser]
OK, well unless I'm mistaken, you only need to use having when you're using an aggregate function, which none of the current having statements are. Try moving them to the where and only including in having what actually needs to be there.

Can you also post the php?
#5

[eluser]obiron2[/eluser]
I think you need to put the ITA in quotes as it is a value, otherwise SQL will think it should be a column name.

If you are building the query on the fly, you will need to concatenate the opening quotes and closing quotes and/or pass the language as a variable

obiron
#6

[eluser]obiron2[/eluser]
Fantastic looking site by the way.

for anyone wnating to do E-commerce, I would recommend looking at this for ease of use.

Obiron
#7

[eluser]daweb[/eluser]
[quote author="dmorin" date="1226962572"]OK, well unless I'm mistaken, you only need to use having when you're using an aggregate function, which none of the current having statements are. Try moving them to the where and only including in having what actually needs to be there.

Can you also post the php?[/quote]

Thank you. I solved just using where clause.
#8

[eluser]daweb[/eluser]
Oh my God Obiron,

thank you so much :-D

I'm doing the VI e-commerce restyling at the moment... very nice.. I hope...
#9

[eluser]Flemming[/eluser]
I have to agree - great looking/working site!

sorry to hi-jack this but how do your URIs work?

e.g. /english/taggiasca_olives/taggian_olives_extra_virgin_oil/502

I guess the last part is the product ID but the rest can't be controller/method ... would you mind sharing how your routing is working?
#10

[eluser]daweb[/eluser]
It's not me!! It's thanks to the great works of this community and, of course, the simply power of CI...

Code:
$route['default_controller'] = "prodotti_tipici";

# language routes  
$route['(italiano)'] = "prodotti_tipici";  
$route['(english|italiano)'] = "prodotti_tipici";  

$route['(english|italiano)/([a-z_-]+)/([0-9]+)$'] = 'prodotti_tipici/catalogo/$1/$2';
$route['(english|italiano)/([a-z_-]+)/([a-z_-]+)/([0-9]+)$'] = 'prodotti_tipici/prodotto/$1/$2/$3';




Theme © iAndrew 2016 - Forum software by © MyBB