i have two class
<?php
class PublicInformation extends CActiveRecord{
.....
public function relations(){
return array(
'Certificate' => array(self::HAS_MANY, 'Certificate', 'applicantId'),
);
}
}
?>
And
<?php
class Certificate extends CActiveRecord{
..........
public function relations(){
return array(
'PublicInformation' => array(self::BELONGS_TO, 'PublicInformation', 'applicantId'),
);
}
}
?>
i try to join these databases:
$applicantInfo = PublicInformation::model()->with('Certificate')->findByAttributes(array('applicantId'=>$applicantId));
but i got error
C:\WampServer\www\Keramos\yii\db\ar\CActiveFinder.php(706)
00694: {
00695: // determine the primary key value
00696: if(is_string($this->_pkAlias)) // single key
00697: {
00698: if(isset($row[$this->_pkAlias]))
00699: $pk=$row[$this->_pkAlias];
00700: else // no matching related objects
00701: return null;
00702: }
00703: else // is_array, composite key
00704: {
00705: $pk=array();
00706: foreach($this->_pkAlias as $name=>$alias)
00707: {
00708: if(isset($row[$alias]))
00709: $pk[$name]=$row[$alias];
00710: else // no matching related objects
00711: return null;
00712: }
00713: $pk=serialize($pk);
00714: }
00715:
00716: // retrieve or populate the record according to the primary key value
00717: if(isset($this->records[$pk]))
00718: $record=$this->records[$pk];
i traced the codes and i find that the $this->_pkAlias is null
where is the problem ?