purekid / mongodm

MongoDB ORM that includes support for references,embed and multilevel inheritance.
MIT License
200 stars 47 forks source link

Mongodm can not be use in Phalcon? #85

Closed wughvor closed 9 years ago

wughvor commented 9 years ago

I have this question when create new model: Argument 2 passed to Purekid\Mongodm\MongoDB::__construct() must be of the type array, null given, called in C:\xampp\htdocs\guppys\common\Library\Vendor\purekid\mongodm\src\Purekid\Mongodm\MongoDB.php on line 66 and defined

jrschumacher commented 9 years ago

@wughvor can you give more context, show some code?

wughvor commented 9 years ago

@jrschumacher hi, I use mongodm in Phalcon:

// User.php class User extends \Purekid\Mongodm\ { static public $collection = 'user'; protected static $attrs = array( 'name' => array('type' = 'string'), ); }

class UserManager { public function create() { $user = new User(); $user->name = 'somebody'; $user->save(); } }

// IndexController.php class IndexController extends \Phalcon\Mvc\Controller { public function indexAction() { $user = new User(); $user->name = 'somebody'; $user->save(); // This is ok, will save the somebody user in mongo }

   public function createAction()
   {
       $userManager = new UserManager();
       $userManager->create(); // This is fail, and error like "Argument 2 passed to Purekid\Mongodm\MongoDB::__construct() must be of the type array, null given, called" will show.
   }

}

I want to use some middle class to manage the models, like UserManager, but it' will show error message when create the UserManager in Controller.

This is my question, Thank you

jrschumacher commented 9 years ago

How are you setting up the database? https://github.com/purekid/mongodm/blob/master/README.md#setup-database

wughvor commented 9 years ago

@purekid , Thank you!!, I resolve this question by your suggestion. also thanks you, @jrschumacher

wughvor commented 9 years ago

@purekid , Thank you!!, I resolve this question by your suggestion. also thanks you, @jrschumacher