complex way: create a table searches with fields for all conditions: id user_id bedrooms price area_id and its Model
and save your condition: user_id = 2 bedrooms = 3 price = 'BETWEEN 500 AND 600' area_id = '000002,000003' // in string format, choose a separator and: // get user conditions from db $conditions = $this->Search->read(null, $search_id); // convert some fields, would be better in afterFind in Search Model $conditions['Search']['area_id'] = explode(',', $conditions['Search'] ['area_id']); // to recover array from string // search properties with conditions $properties = $this->Property->findAll($conditions); I didn't tested this code, but you've the idea. Tell me if you have questions On 21 août, 17:12, djiize <[EMAIL PROTECTED]> wrote: > simple way: > you can serialize your conditions array in a new fieldhttp://php.net/serialize > but beware of future DB modifications (field renaming, etc...) > > On 21 août, 16:00, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > I'm building a property site (trying anyway!) > > > I've constructed my search $conditions from the data submitted in the > > search form - it gives me an array: > > > Array ( [Letting] => Array ( [bedrooms] => 3 [price] => BETWEEN 500 > > AND 600 [area_id] => Array ( [0] => 000002 [1] => 000003 ) ) ) > > > which in the SQL request gets converted by CAKE into: > > > WHERE (`bedrooms` = 3) AND (`price` BETWEEN '500' AND '600') AND > > (`area_id` IN (000002, 000003) ) > > > but I want to offer the option for the user to save these search > > criteria so the site will email new property details to the user > > automagically. > > > If I split the $conditions array apart I'll need to save four or more > > separate rows and build logic to reconstruct them when the time comes > > to check for new properties. > > > Can I just grab the complete query (without running it) and cram it > > into a field? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---