osclass/OSClass — Issue #83: SQL error if using picture only items on homepage
Author: Haiderx
Created: 2011-12-18 16:56:19+00:00
State: open

To allow only items with pictures on homepage, I added the following line in osc_count_latest_items() function:
$search->withPicture(TRUE);

It worked perfectly in v2.2.2. However in v2.3.3 if you add this line to osc_count_latest_items() function the sql that is generated returns the following error:
#1054 - Unknown column 'oc_t_item_resource.s_content_type' in 'where clause'

The resulting sql is:
SELECT oc_t_item.*, oc_t_item_location.*, cd.s_name as s_category_name FROM oc_t_item, oc_t_item_location, oc_t_category, oc_t_category_description as cd WHERE oc_t_item_location.fk_i_item_id = oc_t_item.pk_i_id AND oc_t_item.b_active = 1 AND oc_t_item.b_enabled = 1 AND oc_t_item.b_spam = 0 AND (oc_t_item.b_premium = 1 || oc_t_category.i_expiration_days = 0 || DATEDIFF('2011-12-18 14:38:32', oc_t_item.dt_pub_date) < oc_t_category.i_expiration_days) AND oc_t_category.b_enabled = 1 AND oc_t_category.pk_i_id = oc_t_item.fk_i_category_id AND oc_t_item_resource.s_content_type LIKE '%image%' AND oc_t_item.pk_i_id = oc_t_item_resource.fk_i_item_id AND oc_t_item.fk_i_category_id = cd.fk_i_category_id GROUP BY oc_t_item.pk_i_id ORDER BY dt_pub_date DESC LIMIT 0, 25

This sql is very much different from the sql that was generated in v2.2.2