On Nov 21, 3:23 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> I agree - it gets pretty convoluted when you add a bit of complexity
> into the conditions.
Where is the complexity in the stated example?
Any nested array that is written on a single line is going to be
'difficult' to read as such it's easier to read if it's written as:
$conditions['OR']['PromoCode.start_date'] = "> $datetime";
$conditions['OR']['PromoCode.promo_code'] = $promo_code;
$conditions['NOT']['PromoCode.active'] = 1; // or
$condiions['PromoCode.active'] = '<> ' . 1;
$count =$this->PromoCode->findCount($conditions);
OR as:
$conditions = array(
'OR' => array(
'PromoCode.start_date' => "> $datetime",
'PromoCode.promo_code' => $promo_code
)
'NOT' => array('PromoCode.active' => 1) // or 'PromoCode.active' =>
'<> ' . 1
);
$count =$this->PromoCode->findCount($conditions);
Both of which are unambiguos (, identical) and easy to read. If you /
do/ write a more complex constraint you'll find it's quite easy to do
so if you adopt on or the other means of writing them.
my 2c, hth,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---