relational activerecords on mysql views - how to setup primary keys

I want to create relational activerecord on a mysql view.

You cannot set primarykeys on mysql view's, so the command

$calls=TblCall::model()->with(‘viewContact’)->findAll();

result in an error:

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘t1.’ in ‘on clause’

Source File

/srv/www/vhosts/linus.datatraders.own/yii-1.0.6.r1102/framework/db/CDbCommand.php(318)

00306:            }

00307:

00308:            if($this->_connection->enableProfiling)

00309:                Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');

00310:

00311:            return $result;

00312:        }

00313:        catch(Exception $e)

00314:        {

00315:            if($this->_connection->enableProfiling)

00316:                Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');

00317:            Yii::log('Error in querying SQL: '.$this->getText().$params,CLogger::LEVEL_ERROR,'system.db.CDbCommand');

00318: throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',

00319:                array('{error}'=>$e->getMessage())));

00320:        }

00321:    }

00322: }

everything is fine if i use a normal mysql table with primarykey…

How can I set a column as primary key in the activerecord childclass?

Best regards - Jens

It is not officially supported to use AR with views.

Having said that, you may try overriding primaryKey() method in your AR class.

thank's a lot … that is exactly what i need…