Hello,
I'm putting myself through the beginning paces with Yii. I've noticed that Gii's been having some trouble defining model relations if my tables are prefixed with tbl_. I've three tables, tbl_project, tbl_user and a join table, tbl_project_user_assignment.
When I generate the crud for tbl_project it defines the relationship with tbl_user as tblUser, not user. If I drop the tbl_ prefix everything works fine, so it's not a huge deal, but it does make me wonder if I'm doing something wrong.
Can anybody shed some light on this?
Thanks,
JW
Page 1 of 1
Gii and Tbl_ Relations
#2
Posted 29 January 2011 - 01:59 PM
Did you configured your config (main.php) file to have 'tbl_' prefix?
'db'=>array( // ..... 'tablePrefix' => 'tbl_', //<--- ),
¿How long would it take for you to understand that you own nothing in this world?
www.ramirezcobos.com
www.ramirezcobos.com
#3
Posted 02 May 2011 - 04:19 AM
Antonio Ramirez, on 29 January 2011 - 01:59 PM, said:
Did you configured your config (main.php) file to have 'tbl_' prefix?
'db'=>array( // ..... 'tablePrefix' => 'tbl_', //<--- ),
It's the clue , I had such problem and when I added this code it solved!
You can do anything, but not everything.
#4
Posted 30 December 2011 - 12:59 AM
Antonio Ramirez, on 29 January 2011 - 01:59 PM, said:
Did you configured your config (main.php) file to have 'tbl_' prefix?
'db'=>array( // ..... 'tablePrefix' => 'tbl_', //<--- ),
I have a similar problem.
I have created tables for my current project, without the tbl_ prefix.
But now i have installed the fbgallery extention which uses tbl_
When i run the page i get an error not being able to find the tables because they are looking for names tables without this prefix...
What would be the best solution when working with two different table naming standards ?
Thank you
#5
Posted 31 December 2011 - 10:56 AM
Turns out that setting that prefix in my main, will not affect non prefixed tables, and everything works just fine. Im not sure how it works , but it does... Maybe someone could shed some light on this ?
Thanks
Thanks
#7
Posted 11 December 2012 - 07:46 PM
qinsanep, on 31 December 2011 - 10:56 AM, said:
Turns out that setting that prefix in my main, will not affect non prefixed tables, and everything works just fine. Im not sure how it works , but it does... Maybe someone could shed some light on this ?
Thanks
Thanks
I get very similar error:
'tblDiscounts' => array(self::MANY_MANY, 'Discounts', '{{orders_discs}}(orders_id, discounts_id)'),as you can see tbl_orders_discs is replace because I added prefix tbl_ to the main config, however I get anoying tblDiscounts as a veriable to define the relation.
Here is the top of my model:
* The followings are the available model relations: * @property Users $user * @property Files $file * @property Discounts[] $tblDiscounts
it seems that the problem rises when I have many to many relationship. Removing the tbl prefix from main config doesn't help. Also adding and removing tbl prefix in the Gii menu didn't help.
Share this topic:
Page 1 of 1

Help














