That is how I do it in a very complex find condition:
$param = array();
$param['Hotelmaster.deleted'] = '0';
if($this->data['Hotelmaster']['name'])$param['Hotelmaster.name LIKE'] =
'%'.trim($this->data['Hotelmaster']['name']).'%';
if($this->data['Hotelmaster']['buchungscode1'] &&
strlen($this->data['Hotelmaster']['buchungscode1'])>2){
$param['or'] = array (
'Hotelmaster.buchungscode1 LIKE' =>
'%'.strtoupper(trim($this->data['Hotelmaster']['buchungscode1'])).'%',
'Hotelmaster.buchungscode2 LIKE' =>
'%'.strtoupper(trim($this->data['Hotelmaster']['buchungscode1'])).'%',
'Hotelmaster.buchungscode3 LIKE' =>
'%'.strtoupper(trim($this->data['Hotelmaster']['buchungscode1'])).'%',
'Hotelmaster.buchungscode4 LIKE' =>
'%'.strtoupper(trim($this->data['Hotelmaster']['buchungscode1'])).'%');
}if($this->data['Hotelmaster']['exklusiv'])$param['Hotelmaster.exklusiv'] =
$this->data['Hotelmaster']['exklusiv'];
if($this->data['Hotelmaster']['kategorie'])$param['Hotelmaster.kategorie'] =
$this->data['Hotelmaster']['kategorie'];
if($this->data['Hotelmaster']['zielgebietmaster_id'])$param['Hotelmaster.zielgebietmaster_id']
= $this->data['Hotelmaster']['zielgebietmaster_id'];
if($this->data['Hotelmaster']['ortmaster_id'])$param['Hotelmaster.ortmaster_id']
= $this->data['Hotelmaster']['ortmaster_id'];
Hope that example helps
Anja
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag
von rb
Gesendet: Donnerstag, 19. Februar 2009 20:00
An: CakePHP
Betreff: Re: Search db with find & conditions
The good news:
I was able to get it working (thanks!)
The bad news:
I'm now trying to append a LIKE condition, and I'm not appending the
conditions array correctly. Every time I attempt to append the LIKE condition,
it overwrites anything previously appended to the array, as well as does some
other funky stuff.
************************************************************
$formSchools = $this->data['schools'];
$conditions = array();
if(!empty($formSchools['zip_mail']))
$conditions['School.zip_mail'] = $formSchools['zip_mail'];
if(!empty($formSchools['name']))
$conditions = "School.name LIKE '%{$formSchools['name']}%'";
if(!empty($formSchools['street_mail']))
$conditions['School.street_mail'] = $formSchools['street_mail'];
if(!empty($formSchools['state_province'])
$conditions['School.state_mail'] = $formSchools['state_province'];
************************************************************
I've tried a few different ways, but still not achieving the correct array
structure.
So basically my question, How do you append a LIKE condition into the
$conditions array?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---