Yii Postgresql Primary Key Problem

Hi Guys !

I have just migrated Mysql to Postgresql but I’m getting this error when I execute my app .





Invalid argument supplied for foreach()


/home/cahit/public/yii/framework/db/ar/CActiveFinder.php(826)


814     {

815         // determine the primary key value

816         if(is_string($this->_pkAlias))  // single key

817         {

818             if(isset($row[$this->_pkAlias]))

819                 $pk=$row[$this->_pkAlias];

820             else    // no matching related objects

821                 return null;

822         }

823         else // is_array, composite key

824         {

825             $pk=array();

826             foreach($this->_pkAlias as $name=>$alias)

827             {

828                 if(isset($row[$alias]))

829                     $pk[$name]=$row[$alias];

830                 else    // no matching related objects

831                     return null;

832             }

833             $pk=serialize($pk);

834         }

835 

836         // retrieve or populate the record according to the primary key value

837         if(isset($this->records[$pk]))

838             $record=$this->records[$pk];




What’s the problem ?

How do you define the model? It’s class name should be somewhere in the stack trace provided with the error message.

I solved my problem. I have relation between two tables .In my second table, Primary key is missed so it gives above error. After I added primary key to second table I fixed my problem . Thank you.