hi all,
I am trying to execute query with some posted value the query is
like this
$sql = "SELECT DISTINCT `csd`.`store_id` ,`csd`.`campaign_id`, `csd`.`date`
, `c`.`campaign_id` , `c`.`supplier_id` , `cm`.`sub_category_id`
FROM `campaign_store_dates` AS `csd`
LEFT JOIN `campaigns` AS `c` ON `csd`.`campaign_id` = `c`.`campaign_id`
LEFT JOIN `campaign_media` AS `cm` ON `c`.`campaign_id` = `cm`.`campaign_id`
WHERE `c`.`status` NOT
IN (
'request', 'cancelled'
) AND `csd`.`store_id` != '0'
";
if (!empty($strDate) and !empty($endDate)){
$sql .= " AND `csd`.`date` BETWEEN '$strDate' AND
'$endDate'";
}
if (isset($sub_category_id)){
$sql .= " AND `cm`.`sub_category_id` = {$sub_category_id}";
}
in if condition i am checking wether the value is there r not the query is
working fine when value is set. if value is not set at that time the query
is not working and giving error like
*SQL Error:* 1054: Unknown column 'empty' in 'where clause'
please give me sugitions
Thanks in advance
A.RAKESH
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en