[Solar-talk] Changes afoot: a new Model class

Travis Swicegood development at domain51.com
Thu Feb 8 07:22:05 PST 2007


Hopefully the Spamhaus issue is fixed and this comes through :-)


Rodrigo Moraes wrote:
> The problem Paul mentioned is how to make the automatic model finding
> in _hasOne() / _hasMany() relationships if the names are, let's say,
> all singular. Keeping the example of the 'post' model:
>
>     $this->_hasOne('blog');
>     $this->_hasMany('comment');
>   

The simplest solution here is simple plural.  Everything has a "s" added 
to the end of it if it's plural.  It doesn't necessarily look as 
elegant, but it does remove an extra layer while still allowing you to 
differentiate.

That said, it's not the difficult for this to figure out what it should do:

    $model->blog
    $model->comments
    $model->comment

There's only so many places __get() can look to figure out what to do 
with those.

-Travis

   


More information about the solar-talk mailing list