Hey,

I'm trying to build find function for many days with no luck, please
help me guys.

Models:

mysql> DESCRIBE adverts;
+----------------+------------------------+------+-----+---------
+----------------+
| Field          | Type                   | Null | Key | Default |
Extra          |
+----------------+------------------------+------+-----+---------
+----------------+
| id
| user_id
| ad_category_id
| code
| valid
| bad
| created
+----------------+------------------------+------+-----+---------
+----------------+

mysql> DESCRIBE ads_autos;
+--------------------+------------------+------+-----+---------
+----------------+
| Field              | Type             | Null | Key | Default |
Extra          |
+--------------------+------------------+------+-----+---------
+----------------+
| id
| advert_id
| ad_manufacturer_id
| ad_model_id
| ad_type_id
| year
| ad_fueltype_id
| ad_door_id
| ad_colour_id
| capacity
| cilinders
| power
| ad_gearbox_id
| gears
| pricein
| priceout
| ta
| milage
| comment
| name
| phone
| email
| ad_country_id
| ad_city_id
+--------------------+------------------+------+-----+---------
+----------------+

mysql> DESCRIBE ad_images;
+-----------+------------------+------+-----+---------+----------------
+
| Field     | Type             | Null | Key | Default | Extra
|
+-----------+------------------+------+-----+---------+----------------
+
| id
| advert_id
| url
| created
+-----------+------------------+------+-----+---------+----------------
+

mysql> DESCRIBE advert_comfort;
+-----------+------------------+------+-----+---------+----------------
+
| Field     | Type             | Null | Key | Default | Extra
|
+-----------+------------------+------+-----+---------+----------------
+
| id
| advert_id
| option_id
+-----------+------------------+------+-----+---------+----------------
+



Models and associations:

Advert hasMany AdImage
Advert hasMany AdvertComfort
Advert hasOne AdsAuto

I need find function, when there are such conditions, for example:

AdsAuto.year from .. to ..
AdvertComfort.option_id is 1,7,8 ...
and Advert has at least one AdImage (photo)

I tried many ways with Containable, INNER JOIN but with no luck.  I
can't get all these conditions in one query, but i need to get Advert
model results if only all conditions are true.


P.S. sorry for my bad english

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to