[Solar-talk] _hasOne Help

Raymond Kolbe rkolbe at gmail.com
Wed Nov 14 14:44:22 CST 2007


Apparently now (after trying somethings) I can get $rest->markets to return
the markets record just fine...

On Nov 14, 2007 3:23 PM, Raymond Kolbe <rkolbe at gmail.com> wrote:

> The problem is that each restaurant is assigned to only 1 market. Putting
> things in NF means that the restaurant table will have a FK pointing to the
> PK of the markets table.
>
> Using your example (not the pastbin, but from above), it returns NULL now
> when trying to get $rest->market->name or $rest->markets->name. Is there
> another way I should try accessing the data?
>
>
> On Nov 14, 2007 3:08 PM, Rodrigo Moraes <rodrigo.moraes at gmail.com> wrote:
>
> > Ok, I got confused because of your "inverted" hasOne. Normally I set
> > it so that the *foreign table* has the foreign col (example is
> > pastebin [1]).
> >
> > So, in your scheme, this would work.
> >
> > // In Restaurants model:
> >
> >    $this->_hasOne('markets', array(
> >      'foreign_class' => 'Vendor_Model_Markets',
> >      'native_col'    => 'market',
> >      'foreign_col'  => 'id',
> >    ));
> >
> > // In Markets model:
> >
> >    $this->_belongsTo('restaurants', array(
> >      'foreign_class' => 'Vendor_Model_Restaurants',
> >      'foreign_col'   => 'market',
> >      'native_col'    => 'id',
> >    ));
> >
> > ..and Paul can explain this a little better. And because I can't, I'd
> > use a setup that I understand, which would be:
> >
> > [1] http://pastebin.com/m3fb2a146
> >
> > :)
> >
> > -- rodrigo
> > _______________________________________________
> > Solar-talk mailing list
> > Solar-talk at lists.solarphp.com
> > http://mailman-mail3.webfaction.com/listinfo/solar-talk
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20071114/920e28ec/attachment.html


More information about the Solar-talk mailing list