Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

One-To-One Unidirectionnal

$
0
0
Hi eveyrone,

I'm trying to make one to one unidirectionnal. The problem is, it does not work. Here is my entities:

class A extends CActiveRecord {

    public function relations() {
        return array(
            'logbook' => array(self::BELONGS_TO, 'Logbook', 'logbook_id'),
        );
    }

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }
}

?>

class Logbook extends CActiveRecord {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

}


I'm doing this:
$a = new A();
$b = new Logbook();

$a->logbook = $b;
$a->save();


But the foreign key 'logbook_id' is not set! And logbook has not been persisted.
Need some help please.

Viewing all articles
Browse latest Browse all 18717


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>