[Solar-talk] _hasOne Help
Raymond Kolbe
rkolbe at gmail.com
Wed Nov 14 09:13:29 CST 2007
Hey folks,
I am in need of some help with doing a _hasOne relationship in my model. I
do not have the specifics with me at the moment but in a simple world let's
say my DB is setup like this
COMPANY (the table name)
id (PK)
name
market (FK -> MARKET_id)
MARKET
id (PK)
name
Now, with the example on the wiki, _hasMany is used and there are 3 tables
involved. I do not wish to create another table for the above relationship
(and I'm sure I do not have to).
I have setup my models so that Vendor_Model_Company uses _hasOne but
Vendor_Model_Market does NOT use _belongsTo (should it?). After
instantiating Vendor_Model_Company, I tried something like:
(rough code...not exact...probably doesn't work)
$company = new Vendor_Model_Company;
$company->fetchAll(...whatever options here);
$company->name; //returns name of the company
$company->market; //returns null
$company->market->name; //returns null
I wish I had the exact code with me right now but I do not. With the tests I
have tried, I keep getting results like the above. I used Solar::dump() to
return my values.
Any help is appreciated ^_^
Thanks,
Raymond K.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20071114/3e340742/attachment-0001.html
More information about the Solar-talk
mailing list