Mongodb is runnig . I don't understand what is the problem. Please help me!
app/config.yml
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
Controller
namespace fuar\sergiBundle\Controller;
use fuar\sergiBundle\Entity\Produc t;
use Symfony\Bundle\FrameworkBundle \Controller\Controller;
use Symfony\Component\HttpFoundati on\Response;
class DefaultController extends Controller
{
public function indexAction()
{
$product = new Product();
$product->setName("xxx");
$product->setAge('25');
$product->setSchool("xxxx");
$dm = $this->get('doctrine_mongodb') ->getManager();
$dm->persist($product);
$dm->flush();
return new Response('Created product id '.$product->getId());
}
}
fuar/sergiBundle/Entity/Produc t.php
namespace fuar\sergiBundle\Entity;
use Doctrine\ODM\MongoDB\Mapping\A nnotations as MongoDB;
/**
* Product
*/
class Product
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $name;
Cross-referencing this with: https://github.com/doctrine/ DoctrineMongoDBBundle/issues/ 275, which has been answered.
댓글 없음:
댓글 쓰기