checking posted data
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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: checking posted data
On Tue, Jul 20, 2010 at 9:20 AM, rakeshyadav rakeshyadav rakeshyadav@gmail.com wrote: 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. Which value? 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 debug($sql); It's a somewhat complicated query but, at a glance, it looks like you could do this same thing using find() and ContainableBehavior. 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: checking posted data
On Tue, Jul 20, 2010 at 9:48 PM, cricket zijn.digi...@gmail.com wrote: On Tue, Jul 20, 2010 at 9:20 AM, rakeshyadav rakeshyadav rakeshyadav@gmail.com wrote: 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. Which value? I am sorry the value is $sub_category_id 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 debug($sql); It's a somewhat complicated query but, at a glance, it looks like you could do this same thing using find() and ContainableBehavior. 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en