Re: Countries, States and Cities: Which relations i'm dealing with?
Hi ZAKy,
your idea would work, I think...
For a country that has no states at all, I would use the country
itself as its state... Would be a solution. Not quite elegant, but
well...
I have other ideas referring to my problem:
What about 2 new tables cities_countries and cities_states... would be
2 HABTMs, but i cannot use them as hasOnes?
Or add to the cities table two new columns capital_state_id and
capital_country_id that can be NULL... So if a city is capital of a
country and not of a state p.e. capital_state_id would be NULL and
capital_country_id the id of its country.
But anyway: I like your idea to think in capital as an attribute of
city.
On 19 Aug., 01:41, ZAky <procsh...@gmail.com> wrote:
> I think capital is a city attribute there for should be a column in
> thecitiestable.
> The values of the column can be 0 = not a capital, 1= state capital, 2
> = country capital, 4 = state and country capital.
> It also solve the empty combobox.
> Another way to solve the empty combobox is to add "N/A" row to thecitiestable and select this value before addingcities.
> One more issue, country may have no states at all.
>
> On Aug 19, 12:17 am, DerBjörn <b.unkh...@googlemail.com> wrote:
>
> > Thanks, Dan!
>
> > After I rebaked my models with followingrelations:
>
> > City belongsTo State
>
> > State belongsTo Country
> > State belongsTo City
> > State hasMany City
>
> > Country belongsTo City
> > Country hasMany State
>
> > and updated my views, finally i got a "result"...
> > Your advice with "containable" i haven't follow till now.
>
> > I still have one problem that maybe i am able to solve with cricket's
> > advice of using virtual models!?!
> > When i want to add p.e. a new country or a new state, their comboboxes
> > for capital city are empty, so i cannot choose its capital city. How
> > do I solve this problem?
> > Thanks a lot :)
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home