tablePrefix problem

Hi!

I was wondered when I tried to configure the tablePrefix property and after that I saw an exception :

"The table "{{users}}" for active record class "Users" cannot be found in the database".

It doesn’t work neither in PDA nor in Active Records. That’s my configuration from main.php file:


'db'=>array(

    'class'=>'CDbConnection',

    'connectionString'=>'pgsql:host=localhost;port=5432;dbname=postgres',

    'username'=>'postgres',

    'password'=>'root',

    'charset'=>'utf8',

    'tablePrefix'=>'rtc_',

),

Table name is "rtc_users". And i write in SiteController.php:




$connection=new CDbConnection(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password);


$connection->active=true;

		

$post=new Users;

$post->username='admin';

$post->email='admin@admin.ru';

$post->save();



And that’s models/Users.php file:


<?php


class Users extends CActiveRecord

{

    public static function model($className=__CLASS__)

    {

        return parent::model($className);

    }

 

    public function tableName()

    {

        return '{{users}}';

    }


}

Which version Yii you have?

Maybe should be:




public function tableName()

    {

        return '{{Users}}';

    }

I have 1.1.0. “{{Users}}” doesn’t work anyway…

I had the same problem using Postgres, and I believe it’s due to a bug in the way Yii uses the “{{tablename}}” placeholder in PDO named bindings. The value is being bound as “{{tablename}}”, when it should actually be bound as prefix.tablename

If you look at http://code.google.com/p/yii/issues/detail?id=1039 you can see what I did to get it working