Closed wughvor closed 9 years ago
@wughvor can you give more context, show some code?
@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
How are you setting up the database? https://github.com/purekid/mongodm/blob/master/README.md#setup-database
@purekid , Thank you!!, I resolve this question by your suggestion. also thanks you, @jrschumacher
@purekid , Thank you!!, I resolve this question by your suggestion. also thanks you, @jrschumacher
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