Hi, I just recently found a case where I need to use a HAS_ONE relation but defining a foreign key in a table generates a HAS_MANY relation in the model when using Gii. How can I get a HAS_ONE relation?
Thanks in advance.
Page 1 of 1
How Gii Recognizes Has_One Relations
#2
Posted 15 November 2012 - 02:30 AM
just change generated self::HAS_MANY to self::HAS_ONE
there is no difference in database representations of both cases so the generator cannot determine which to choose, but HAS_MANY covers all possibilities (when there is only one dependent record you will just get one record in array). Also - this is main benefit of scaffolding scenario: you generate base code but then you can adapt it and change the way you want
there is no difference in database representations of both cases so the generator cannot determine which to choose, but HAS_MANY covers all possibilities (when there is only one dependent record you will just get one record in array). Also - this is main benefit of scaffolding scenario: you generate base code but then you can adapt it and change the way you want
red
Share this topic:
Page 1 of 1

Help














