Trying to convert my sql queries to dql, it seems like I'm doing something wrong.
I need basic connections, something like this.
SELECT a.id, a.title, u.name FROM articles JOIN users ON a.author_id = u.id
I tried
SELECT a.id, a.title, u.name FROM Article a JOIN User u WITH a.author_id = u.id
Getting error
[Semantical Error] line 0, col 34 near 'Article a JOIN': Error: Class 'Article' is not defined.
How do I determine? Could you give me the right solution?
Edit:
The essence of the article
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
class Article
{
protected $id;
protected $title;
protected $authorId;
protected $creationDate;
protected $shortContent;
protected $content;
public function getId()
{
return $this->id;
}
public function getTitle()
{
return $this->title;
}
public function getAuthorId()
{
return $this->authorId;
}
public function getCreationDate()
{
return $this->creationDate;
}
public function getShortContent()
{
return $this->shortContent;
}
public function getContent()
{
return $this->content;
}
}
User organization
<?php
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
class User extends BaseUser
{
protected $id;
protected $phone;
protected $gender;
protected $about;
public function getPhone()
{
return $this->phone;
}
public function getGender()
{
return $this->gender;
}
public function getAbout()
{
return $this->about;
}
}
source
share