试图将我的SQL查询转换为dql,似乎我做错了.
我需要基本的连接,就像这样.
SELECT a.id, a.title, u.name FROM articles JOIN users ON a.author_id = u.id
Run Code Online (Sandbox Code Playgroud)
试着
SELECT a.id, a.title, u.name FROM Article a JOIN User u WITH a.author_id = u.id
Run Code Online (Sandbox Code Playgroud)
得到错误
[Semantical Error] line 0, col 34 near 'Article a JOIN': Error: Class 'Article' is not defined.
Run Code Online (Sandbox Code Playgroud)
我该如何定义?你能给我一个正确的解决方案吗?
编辑:
文章实体
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="articles")
*/
class Article
{
/**
* @var integer $id
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected …Run Code Online (Sandbox Code Playgroud) 我正在尝试自己的身份验证类.
这是我的用户实体.
<?php
namespace AppBundle\Entity;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class User
{
/**
* @ORM\Column(type="int", length="11")
*/
protected $id;
/**
* @ORM\Column(type="string", length="25")
*/
protected $login;
/**
* @ORM\Column(type="string", length="25")
*/
protected $password;
/**
* @ORM\Column(type="string", length="25")
*/
protected $firstName;
/**
* @ORM\Column(type="string", length="25")
*/
protected $lastName;
/**
* @ORM\Column(type="string", length="25")
*/
protected $email;
public function getId()
{
return $this->id;
}
public function getLogin()
{
return $this->login;
}
public function getPassword()
{
return $this->password; …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装w .. 正如文档建议的那样,我使用pip安装wag:
tigran@tigran:~/projects/website$ pip install wagtail
Collecting wagtail
Using cached wagtail-1.13.1-py2.py3-none-any.whl
Collecting html5lib<1,>=0.999 (from wagtail)
Using cached html5lib-0.999999999-py2.py3-none-any.whl
Collecting Django<1.12,>=1.8.1 (from wagtail)
Using cached Django-1.11.9-py2.py3-none-any.whl
Collecting djangorestframework<3.7,>=3.1.3 (from wagtail)
Using cached djangorestframework-3.6.4-py2.py3-none-any.whl
Collecting django-treebeard<5.0,>=3.0 (from wagtail)
Collecting Pillow>=2.6.1 (from wagtail)
Using cached Pillow-5.0.0-cp27-cp27mu-manylinux1_x86_64.whl
Collecting Unidecode>=0.04.14 (from wagtail)
Using cached Unidecode-1.0.22-py2.py3-none-any.whl
Collecting django-taggit<1.0,>=0.20 (from wagtail)
Using cached django_taggit-0.22.2-py2.py3-none-any.whl
Collecting django-modelcluster<4.0,>=3.1 (from wagtail)
Collecting Willow<1.1,>=1.0 (from wagtail)
Using cached Willow-1.0-py2.py3-none-any.whl
Collecting beautifulsoup4>=4.5.1 (from wagtail)
Using cached beautifulsoup4-4.6.0-py2-none-any.whl
Collecting requests<3.0,>=2.11.1 (from …Run Code Online (Sandbox Code Playgroud) Symfony 2 遇到一些问题。
尝试使用我的实体从表中获取一些行。
这是实体
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="articles")
*/
class Article
{
/**
* @var integer $id
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string" name="title")
*/
protected $title;
/**
* @ORM\Column(type="int" name="author_id")
*/
protected $authorId;
/**
* @ORM\Column(type="datetime" name="creation_date")
*/
protected $creationDate;
/**
* @ORM\Column(name="string")
*/
protected $content;
public function getId()
{
return $this->id;
}
public function getTitle()
{
return $this->title;
}
public function getAuthorId() …Run Code Online (Sandbox Code Playgroud)