[Solar-talk] _hasOne Help

Rodrigo Moraes rodrigo.moraes at gmail.com
Wed Nov 14 14:08:37 CST 2007


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


More information about the Solar-talk mailing list