Yii Framework Forum: tablePrefix problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

tablePrefix problem Rate Topic: -----

#1 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 01 March 2010 - 01:00 PM

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}}';
    }

}

0

#2 User is offline   qwerty 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 290
  • Joined: 20-November 08

Posted 01 March 2010 - 01:23 PM

Which version Yii you have?

Maybe should be:

public function tableName()
    {
        return '{{Users}}';
    }


0

#3 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 01 March 2010 - 01:54 PM

View Postqwerty, on 01 March 2010 - 01:23 PM, said:

Which version Yii you have?

Maybe should be:

public function tableName()
    {
        return '{{Users}}';
    }



I have 1.1.0. "{{Users}}" doesn't work anyway...
0

#4 User is offline   daren 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 19-March 10

Posted 19 March 2010 - 06:12 AM

View Postfrantic, on 01 March 2010 - 01:00 PM, said:

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".


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.c.../detail?id=1039 you can see what I did to get it working
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users