我是 symfony2 的新手。我创建了一个称为投资组合控制器的基本控制器和该控制器的一些索引视图。我也创建了一个实体类,但它给出了错误。
我的控制器是
<?php
namespace IDP\Bundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class PortfolioController extends Controller {
public function indexAction() {
$product = $this->getDoctrine()
->getRepository('IDPBundle:Portfolio')
->find(1);
return $this->render('IDPBundle:Portfolio:index.html.twig');
}
}
在 src/IDP/Bundle/Entity/Portfolio.php 里面
<?php
namespace IDP\Bundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
class Portfolio
{
private $id;
private $user_id;
private $portfolio_name;
private $description;
private $permalink;
private $sharingCode;
private $shared;
private $shared_portfolio_calls;
private $patentgroup_id;
public function __construct()
{
$this->portfolioGroups = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function setName($portfolio_name)
{
$this->name = $portfolio_name;
}
public function setDescription($description)
{
$this->description = $description;
}
public function getDescription()
{
return $this->description;
}
public function setSharingCode($sharingCode)
{
$this->sharingCode = $sharingCode;
}
public function getSharingCode()
{
return $this->sharingCode;
}
public function setShared($shared)
{
$this->shared = $shared;
}
public function getShared()
{
return $this->shared;
}
public function getUser()
{
return $this->user;
}
}
我的表名称是 pm_portfolios,它包含我在投资组合类中提到的所有字段。
谁能告诉我我做错了什么?