Yii Property "CDbConnection.tableprefix" is not defined.
I’m new to the Yii framework. I created a table named ‘tbl_user’, had set the tablePrefix to ‘tbl_’ in main.php in the ‘db’ array. When I ran the model command from the yii shell script , I got the following:
1 |
|
I removed the tablePrefix entry from main.php. When I ran the model command again, it shows what i want, i have wrote var_dump(Yii::app()->db);
in IndexController.php. it worked!
object(CDbConnection)[13] public ‘connectionString’ =>string‘mysql:host=localhost;dbname=testdrive’(length=37)public* ‘username’ =>string‘root’*(length=4)*public ‘password’ =>string‘528126’*(length=6)public* ‘schemaCachingDuration’ =>int0public ‘schemaCachingExclude’ =>*array(size=0)empty*public ‘schemaCacheID’ =>string‘cache’*(length=5)*public ‘queryCachingDuration’ =>int0public ‘queryCachingDependency’ =>nullpublic ‘queryCachingCount’ =>int0public ‘queryCacheID’ =>string‘cache’*(length=5)*public ‘autoConnect’ =>booleantruepublic ‘charset’ =>string‘utf8’*(length=4)public* ‘emulatePrepare’ =>booleantruepublic ‘enableParamLogging’ =>booleanfalsepublic ‘enableProfiling’ =>booleanfalsepublic ‘tablePrefix’ =>nullpublic ‘initSQLs’ =>nullpublic ‘driverMap’ =>*array(size=9) ‘pgsql’ =>string‘CPgsqlSchema’(length=12) ‘mysqli’ =>string‘CMysqlSchema’(length=12) ‘mysql’ =>string‘CMysqlSchema’(length=12) ‘sqlite’ =>string‘CSqliteSchema’(length=13) ‘sqlite2’ =>string‘CSqliteSchema’(length=13) ‘mssql’ =>string‘CMssqlSchema’(length=12) ‘dblib’ =>string‘CMssqlSchema’(length=12) ‘sqlsrv’ =>string‘CMssqlSchema’(length=12) ‘oci’ =>string‘COciSchema’*(length=10)public* ‘pdoClass’ =>string‘PDO’*(length=3)private* ‘_attributes’ =>*array(size=0)emptyprivate* ‘_active’ =>booleantrueprivate ‘_pdo’ =>object(PDO)[14] private ‘_transaction’ =>nullprivate ‘_schema’ =>nullpublic ‘behaviors’ =>*array(size=0)**empty*private ‘_initialized’ (CApplicationComponent)=>booleantrueprivate ‘_e’ (CComponent)=>nullprivate ‘_m’ (CComponent)=>null
Any idea why I encountered this?
Here’s what I have in main.php.
'db'=>array(
'class=>'CDbConnection',
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '528126',
'charset' => 'utf8',
'tableprefix' => 'tbl_',
),```
Yii Property "CDbConnection.tableprefix" is not defined.
https://ldsun.com/2014/04/15/Yii-Property-CDbConnection-tableprefix-is-not-defined/