Using Different Pgsql Schemas

Hi everyone! I need to retrieve datas from two tables which are in separate schemas (I’m using Postgres 9.2), the default one and a secondary one I create. I’m having problems with the secondary one.

I’m using 2 distinct CDbConnection items to get the two set of datas. I tried setting a tablePrefix attribute so that the original “tableName” becomes “schemaName.tablename”. This is a snippet of my getDbConnection override:

      self::$dbExport = Yii::app()->dbExport;

            if (self::$dbExport instanceof CDbConnection)



                self::$dbExport->tablePrefix = Yii::app()->session['tablePrefix'];

                return self::$dbExport;


however, the parameter is ignored when I invoke it with this command:

	public function getAllRows()



			'select'=>"id, descrizione",

			'condition'=> '1=1',



	    return CHtml::listData($this->findAll(),'id','descrizione');


and I get redirected to the default public schema (the two tables have the same name, so I get to see 2 listings of the same table in "public" instead of one from "public" and the other from a schema named as the prefix.

The variable Yii::app()->dbExport->tablePrefix echoes correctly: it’s like it’s not getting used at all by Yii when preparing the query.

The last thing I tried was surrounding the original "tableName" with curly parenthesis, as in "{{tableName}}" but that just causes my application to throw a CDbException reading "The table "{{tableName}}" for active record class "className" cannot be found in the database. "

I can’t seem to find a workaround :( anybody has a clue?

EDIT: I fixed extending CDbConnection as this other user ->

Any other more “neat” solution is well accepted tho! :)