Hi.
I try to use the yii framework without the CWebApplication class.
So i decided to make my model from scratch.
The Yii-Documentation says, this is the raw frame for an AR-Model:
class Model extends CActiveRecord {
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
Assuming the DB Connection works, the table is called Model, and entry #766 exists, the following should work:
$m = new Model;
try { $m->findByPk(766); }
catch (Exception $e ) { echo "<pre>"; echo $e->getMessage(); print_r ($e->getTrace());
It does not. I get the following Error message:
Column name must be either a string or an array.
Now, my Investigations did come so far:
The classCActiveRecord uses (line 1184)
$criteria=$this->getCommandBuilder()->createPkCriteria($this->getTableSchema(),$pk,$condition,$params)
to get table metadata information.
getTableSchema() uses $this->getMetaData() to gather information.
$this->getMetaData() looks like this:
public function getMetaData()
{
if($this->_md!==null)
return $this->_md;
else
return $this->_md=self::model(get_class($this))->_md;
Now: How the hell is the Primary Key of an Active Record gathered from the database??
I use the pgsql connector.
Any ideas? Thanks for following my thoughts so far, and for any explanation.
Addition: even setting public function primary_key() {return ‘pk_field’; } doesn´t work.