How can i get the actual full table name?

i define the table name in model like:

public function tableName()


    return '{{node}}';


if my tablePrefix set to "yii_" in db config,

how can i get "yii_node" through the model~?

Try AR::model()->tableSchema->rawName.

I haven’t used tablePrefix before so just guessing.

it will be return ‘{{node}}

just wrap by quote~


Have just had to do this myself from within an active record.


This is the way its done in CDbCommand. Don’t know why theres no dedicated method for it!

Wouldn’t this do just fine ?

//Your model : 

public function getOriginalTableName()


   return Yii::app()->db->tablePrefix.str_replace(array('{{','}}'),'',$this->tableName());


Probably, just going with what Yii already uses. Maybe theres some performance considerations?

str_* functions are faster than preg_* functions.


$productTableName = ProductModel::getTableSchema()->fullName;