Fatal error: Call to a member function persist() on a non-object
我正在使用作曲家,mongodb doctrine,php
namespace Documents;
public $document_id;
public $id;
public $model;
public function __construct($model){
$this->model = $model;
$car = new Car('Ford');
dm->persist($car);
dm->flush();
var_dump($car->__toString());
答案 0 :(得分:0)
您的示例中没有定义$dm
变量。请尝试:
$dm = $this->get('doctrine.odm.mongodb.document_manager');
$dm->persist($car);
$dm->flush();
在文档中有详细描述 - http://symfony.com/doc/2.0/bundles/DoctrineMongoDBBundle/index.html