Yii 1.1: yii-one-side-relation

One side relation activerecord behavior
1 follower


Add a dependency to your project's composer.json:


    "require": {
        "petrgrishin/yii-one-side-relation": "~1.0"

Usage examples

Attach behavior to you model

Model have text attribute data for storage relational data

use \CActiveRecord as ActiveRecord;
use \PetrGrishin\OneSideRelation\OneSideRelation;
class Model extends ActiveRecord {
    public function behaviors() {
        return array(
            'testRelation' => array(
                'class' => OneSideRelation::className(),
                'fieldNameStorage' => 'data',
                'relationModel' => RelationModel::className(),

Usage behavior

$model = Model::find(1)->one();
$relatedRecords = $model->testRelation->getRelated();
$model->testRelation->addRelated(new RelationModel());

Be the first person to leave a comment

Please to leave your comment.

Create extension