09-22-2008, 06:29 AM
[eluser]GregX999[/eluser]
In reply to the chicken dish and Joe's Diner examples...
That's perfect, the ability to chain models is very handy! That would make life much easier.
(ie: foreach($restaurant->menu->menu_item as $mi)
It'd be sweet if you could do something like this:
$menuitem = new MenuItem();
$menuitem->where('dish', 'chicken')->where('menu->restaurant', "Joe's Diner"->get();
instead of having to manually do a foreach loop.
Can use "assign" relations before issuing a save call?
Like this:
$restaurant->menu->menu_item = 'Chicken'; (or $restaurant->menu->menu_item->add('Chicken');
$restaurant->save();
Otherwise you'd have to do it like this right?
$restaurant->menu->menu_item->save($new_item); (having already created "$new_item" as a menu_item object
Also, can you delete like this?
$c->where('name', 'Australia')->get()->delete();
As far as requiring join tables for one-one and one-many relationships... I don't think it's valid to say "it was easier to program that way", becuase now it's more work for someone using the library to create more tables. As for not wanting tables to know about each other (and therefore not having foreign keys), it's an interesting way of looking at things. Are there any reasons you can see that would make that a desirable thing? I can't really think of any major pros/cons either way off the top of my head. It's something I certainly could get used to if I started using it.
One thing that could make life easier as far as managing lots of join tables is if you could manually set a join table name "prefix" (in database.php config file for example) so all join tables would appear together in an alphabetical list of table names (using "join_" or "_" for example).
Thanks,
Greg
In reply to the chicken dish and Joe's Diner examples...
That's perfect, the ability to chain models is very handy! That would make life much easier.
(ie: foreach($restaurant->menu->menu_item as $mi)

It'd be sweet if you could do something like this:
$menuitem = new MenuItem();
$menuitem->where('dish', 'chicken')->where('menu->restaurant', "Joe's Diner"->get();
instead of having to manually do a foreach loop.
Can use "assign" relations before issuing a save call?
Like this:
$restaurant->menu->menu_item = 'Chicken'; (or $restaurant->menu->menu_item->add('Chicken');
$restaurant->save();
Otherwise you'd have to do it like this right?
$restaurant->menu->menu_item->save($new_item); (having already created "$new_item" as a menu_item object
Also, can you delete like this?
$c->where('name', 'Australia')->get()->delete();
As far as requiring join tables for one-one and one-many relationships... I don't think it's valid to say "it was easier to program that way", becuase now it's more work for someone using the library to create more tables. As for not wanting tables to know about each other (and therefore not having foreign keys), it's an interesting way of looking at things. Are there any reasons you can see that would make that a desirable thing? I can't really think of any major pros/cons either way off the top of my head. It's something I certainly could get used to if I started using it.
One thing that could make life easier as far as managing lots of join tables is if you could manually set a join table name "prefix" (in database.php config file for example) so all join tables would appear together in an alphabetical list of table names (using "join_" or "_" for example).
Thanks,
Greg