您好,我正在尝试按标题选择行
实体\Pages.php
<?php
namespace Dproc\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @IgnoreAnnotation("fn")
*
*/
/**
* @ORM\Entity
* @ORM\Table(name="pages")
*/
class Pages
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $Id;
/**
* @ORM\Column(type="text")
*/
protected $page_title;
/**
* @ORM\Column(type="text")
*/
protected $page_content;
/**
* @ORM\Column(type="text")
*/
protected $page_category;
/**
* Get Id
*
* @return integer
*/
public function getId()
{
return $this->Id;
}
/**
* Set page_title
*
* @param string $pageTitle
* @return Pages
*/
public function setPageTitle($pageTitle)
{
$this->page_title = $pageTitle;
return $this;
}
/**
* Get page_title
*
* @return string
*/
public function getPageTitle()
{
return $this->page_title;
}
/**
* Set page_content
*
* @param string $pageContent
* @return Pages
*/
public function setPageContent($pageContent)
{
$this->page_content = $pageContent;
return $this;
}
/**
* Get page_content
*
* @return string
*/
public function getPageContent()
{
return $this->page_content;
}
/**
* Set page_category
*
* @param string $pageCategory
* @return Pages
*/
public function setPageCategory($pageCategory)
{
$this->page_category = $pageCategory;
return $this;
}
/**
* Get page_category
*
* @return string
*/
public function getPageCategory()
{
return $this->page_category;
}
}
课程控制器
<?php
namespace Dproc\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Dproc\MainBundle\Entity\Pages;
use Symfony\Component\HttpFoundation\Response;
class CourseController extends Controller
{
public function IndexAction($slug)
{
$page = $this->getDoctrine()
->getRepository('DprocMainBundle:Pages')
->findByPageTitle($slug);
if (!$page) {
throw $this->createNotFoundException('No product found for slug '.$slug);
}
return $this->render('DprocMainBundle:Dproc:single.html.twig',array('page' => $page));
}
}
我试图通过 page_title 找到它,所以我尝试了 findByPageTitle($slug) 但它显示
Entity 'Dproc\MainBundle\Entity\Pages' has no field 'pageTitle'. You can therefore not call 'findByPageTitle' on the entities' repository
我做错了什么,如何按 page_title 选择行