Fatal error: Call to a member function persist() on a non-object

Fatal error: Call to a member function persist() on a non-object

I am using composer,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());

Answers


You haven't got defined $dm variable in your example. Please try:

$dm = $this->get('doctrine.odm.mongodb.document_manager');
$dm->persist($car);
$dm->flush();

It's well described in a documentation - http://symfony.com/doc/2.0/bundles/DoctrineMongoDBBundle/index.html


Need Your Help

Different UI for Dojo DND than when item is displayed

javascript dojo drag-and-drop

I have a set of items that can be dragged / dropped using Dojo DND, that part has already been implemented and all is working well. The specific question I have is that I'd like to display very

IOS MBProgressHUD display location error(it is not center,the loading display on left top.)

ios objective-c position uiactivityindicatorview mbprogresshud

I use MBProgressHUD showWhileExecuting to query some data from network,but the MBProgressHUD is not center sometimes