我正面临着我的学说实体关系的问题.这是事情:
我有2个实体:文章和类别文章是主文章,类别是奴隶
我想从文章中获取分类,而从类别中获取文章.
我做了一个像这样的ManyToMany关系:
class Article
{
/**
* @ORM\ManyToMany(targetEntity="Alpha\BlogBundle\Entity\Category", cascade={"persist"}, inversedBy="Article")
* @ORM\JoinTable(name="article_category")
*/
private $categories;
Run Code Online (Sandbox Code Playgroud)
和
public function __construct(){
$this->categories = new \Doctrine\Common\Collections\ArrayCollection();
Run Code Online (Sandbox Code Playgroud)
和类别实体:
class Category
{
/**
* @ORM\ManyToMany(targetEntity="Alpha\BlogBundle\Entity\Article", cascade={"persist"}, mappedBy="Category")
*/
private $articles;
Run Code Online (Sandbox Code Playgroud)
和
public function __construct(){
$this->articles = new \Doctrine\Common\Collections\ArrayCollection();
Run Code Online (Sandbox Code Playgroud)
在我的文章实体中,我还添加了以下内容:
public function addCategory(\Alpha\BlogBundle\Entity\Category $categories)
{
$this->categories[] = $categories;
$categories->addArticle($this);
return $this;
}
Run Code Online (Sandbox Code Playgroud)
(第四行$categories->addArticle($this);)
在我的控制器中:
public function ajouterAction($data = null, $id = null) {
// On récupère l'EM pour enregistrer en BDD
$em …Run Code Online (Sandbox Code Playgroud) 我想知道关于$jQuery的一些事情.我知道它引用了jQuery对象,但我今天发现了一些不同的东西:$parent
在我正在研究的代码中,这是一个替代$(this).parent:例如:var $parent = $(this).parent();
所以我的问题是,为什么$parent不parent呢?那是唯一的选择器吗?怎么用这种方式?我不是在谈论像$.ajax或的虚线函数$.post.
他妈帮忙