Gii and Tbl_ Relations

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

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!

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

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

Read more here.

/Tommy

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.