2017 © Pedro Peláez
 

library yii-mongo-record

Yii1 MongoDB ActiveRecord model implementation

image

edwardstock/yii-mongo-record

Yii1 MongoDB ActiveRecord model implementation

  • Wednesday, November 18, 2015
  • by edwardstock
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

yii-mongo-record

Yii1 MongoDB ActiveRecord model implementation, (*1)

Features

  • Native Yii1 validation
  • Aggregation Framework Builder
  • Aggregative inherited functions (MongoRecord::count(), MongoRecord::max(), MongoRecord::min(), MongoRecord::distinct($field) etc)
  • Relations between MongoRecord classes BELONGS_TO, HAS_ONE, HAS_MANY and HAS_RELATION_WITHnew (checks for item has related element, if so returns true, another false)
  • MongoDbCriteria - Clone of CDbCriteria for mongo
  • MongoDataProvider - Clone of CActiveDataProvider. U can use it in all standard GridView, ListView etc...
  • MongoPager - paginator
  • MongoSort - sorter special for mongo

Documentation

See link: API DOCUMENTATION, (*2)

Installation

Via composer:, (*3)

require: {
    "edwardstock/yii-mongo-record": "dev-master"
}

Yii configuration

'mongodb' => [
    'class'    => 'common.extensions.Mongo.Connection.MongoDbConnection',
    'host'     => 'localhost',
    'user'     => 'MongoUser',
    'password' => 'MongoPassword',
    'db'       => 'Collection name',
    'port'     => 27017
],

If you have anonymous connection, use next config:, (*4)

'mongodb' => [
    'class'    => 'common.extensions.Mongo.Connection.MongoDbConnection',
    'host'     => 'localhost',
    'db'       => 'Collection name',
],

br/ For more configuration. see MongoDbConnection, (*5)

Basic example

'string'],
        ];
    }
    
    public function beforeSave() {
        
        if($this->isNewRecord) {
            $this->password = Enctyption::passwordHash($this->password);
        }
    
        return parent::beforeSave();
    }

    
}


//creating new user
$user = new User();
$user->username = 'superman';
$user->password = 'myPassword';
if($user->validate()) {
    $user->save();
}

//here u can use id of user by:
$userId = $user->id;


// finding user
$userId = '5644541785992b6c708b4567';
$user = User::model()->findById($userId);

//or u can use MongoId
$user = User::model()->findById(new MongoId($userId));


//deleting
$user->delete();
?>

The Versions

18/11 2015

dev-master

9999999-dev

Yii1 MongoDB ActiveRecord model implementation

  Sources   Download

BSD

The Requires

 

The Development Requires

by Eduard Maximovich

16/11 2015

dev-dev

dev-dev

Yii1 MongoDB ActiveRecord model implementation

  Sources   Download

BSD

The Requires

 

The Development Requires

by Eduard Maximovich

16/11 2015

0.4.0

0.4.0.0

Yii1 MongoDB ActiveRecord model implementation

  Sources   Download

BSD

The Requires

 

The Development Requires

by Eduard Maximovich