Hi,

First post here and also that text was right "probably this question
has been asked before" etc. :)

I must say that first experiences with Cake are wonderful... seems to
save lots of time. Although, one part is totally confusing for
me...it's the hasOne, hasMany, belongsTo... part. So I decided to ask
for guidlines for my specific database to get the clue. (I've read 1.2
manual and examples on net but still confusing..probably problems with
not understanding everything in English)

Scenario:
I need to CRUD car ads...for that I have table "car_ads" which own
fields: id, car_type_id, car_brand_id, car_fuel_id,
car_transmission_id, year, ad_county_id, ad_borough_id, info, price,
car_ad_type_id, added.

each *_id field presents table... for example car_transmission_id
means id from table car_transmissions.
And table "car_transmissions" looks like this: id, transmission (which
has values like: "Automatic", "Manual")

So my main table at this time is car_ads and I have controller for
it... and it also gives me it's table contents with simple index():
        function index() {
                $this->set('carads',$this->CarAd->find('all'));
        }

But I want to see text in the list..not that number which I have on
car_transmission_id field. (Instead of number 1 I would like to see
text: "Automatic")


So here are the questions:

1) Do I have to manually set up Foreign keys for tables?
2) Do I have to build model for each table I need to get id's
from..even if the table itself will stay static ? (model for
car_transmissions, car_fuels_id... tables)
  By static I mean that I don't need to add or delete data from it
because probably there will not be any new transmission types
coming..... I only need to read info from it.


I know 100% that I have to build model for tables which will have
dynamic content...like table car_brand. (new car brand comes.. for ex.
"BMW-Jaguar"..and I need to add it to table from site...not manually)


I'll try to explain it once more..maybe it helps to clear things out:

1) I have table car_ads which will hold car ads... to that table will
be added all kind of info... car brand, car transmission type, fuel
type.. info, make year. Most things should be choosed from other
tables...so when I'm inserting a new ad, I should see dropdown list
for "Car transmission". And when I select from that list "Automatic"
then equaling id will be added to table car_ads into
car_transmission_id field.
2) When I enter the index(), then list of ads will be displayed...but
how to make it show text instead of different id's ?

Currently line looks like this: Brand: 5  Year: 2000 Transmission: 1
Gas: 2
But it should look like this:   Brand: Chevrolet Astro Year: 2000
Transmission: Automatic  Gas: Benzine

I'm able to do MySQL left join for that...it works...but in
CakePHP...it's mystic.

SELECT ca.id, ca.year, ct.transmission, cf.type FROM car_ads ca
LEFT JOIN car_transmissions AS ct ON (ca.car_transmission_id = ct.id)
LEFT JOIN car_fuels AS cf ON (ca.car_fuel_id = cf.id)
WHERE ca.id =1


Big thanks to anyone who helps me getting back on tracks.

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

Reply via email to