Ich bin neu in Doctrine und versuche herauszufinden, wie DQL-Abfrage.Doktrin "Gefällt mir" DQL
Ich habe 2 Einheiten Land und Veranstaltungsort.
Land
<?php
namespace X\application\model\entity;
/** @Entity */
class country
{
/**
* @Id
* @Column(type="string",length=2)
* @GeneratedValue(strategy="NONE")
*/
protected $id;
/** @Column(type="string",length=255,nullable=false) */
protected $name;
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id)
{
$this->id = $id;
}
}
Veranstaltungsort
<?php
namespace X\application\model\entity;
/** @Entity */
class venue
{
/**
* @var \Ramsey\Uuid\Uuid
*
* @Id
* @Column(type="uuid")
* @GeneratedValue(strategy="NONE")
*/
protected $id;
/** @Column(type="string",length=255,nullable=true) */
protected $building;
/** @Column(type="string",length=255,nullable=false) */
protected $street;
/** @Column(type="string",length=255,nullable=false) */
protected $city;
/** @Column(type="string",name="post_code",length=255,nullable=true) */
protected $postCode;
/** @Column(type="string",name="contact_number",length=255,nullable=true) */
protected $contactNumber;
/** @Column(type="text",name="point_of_contact",length=20000,nullable=true) */
protected $pointOfContact;
/** @Column(type="text",length=20000,nullable=true) */
protected $note;
/**
* @ManyToOne(targetEntity="country", inversedBy="id")
**/
protected $country;
/**
* venue constructor.
* @param $building
* @param $street
* @param $city
* @param $postCode
* @param $contactNumber
* @param $pointOfContact
* @param $note
* @param $country
*/
public function __construct($building, $street, $city, $postCode, $contactNumber, $pointOfContact, $note, $country)
{
$this->id = \Ramsey\Uuid\Uuid::uuid4();
$this->building = $building;
$this->street = $street;
$this->city = $city;
$this->postCode = $postCode;
$this->contactNumber = $contactNumber;
$this->pointOfContact = $pointOfContact;
$this->note = $note;
$this->country = $country;
}
/**
* @return \Ramsey\Uuid\Uuid
*/
public function getId()
{
return $this->id;
}
/**
* @param \Ramsey\Uuid\Uuid $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getBuilding()
{
return $this->building;
}
/**
* @param mixed $building
*/
public function setBuilding($building)
{
$this->building = $building;
}
/**
* @return mixed
*/
public function getStreet()
{
return $this->street;
}
/**
* @param mixed $street
*/
public function setStreet($street)
{
$this->street = $street;
}
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return mixed
*/
public function getPostCode()
{
return $this->postCode;
}
/**
* @param mixed $postCode
*/
public function setPostCode($postCode)
{
$this->postCode = $postCode;
}
/**
* @return mixed
*/
public function getContactNumber()
{
return $this->contactNumber;
}
/**
* @param mixed $contactNumber
*/
public function setContactNumber($contactNumber)
{
$this->contactNumber = $contactNumber;
}
/**
* @return mixed
*/
public function getPointOfContact()
{
return $this->pointOfContact;
}
/**
* @param mixed $pointOfContact
*/
public function setPointOfContact($pointOfContact)
{
$this->pointOfContact = $pointOfContact;
}
/**
* @return mixed
*/
public function getNote()
{
return $this->note;
}
/**
* @param mixed $note
*/
public function setNote($note)
{
$this->note = $note;
}
/**
* @return country | null
*/
public function getCountry()
{
return $this->country;
}
/**
* @param mixed $country
*/
public function setCountry($country)
{
$this->country = $country;
}
}
Wenn ich führen Sie diese Abfrage
SELECT venue FROM X\application\model\entity\venue venue WHERE venue.building
LIKE '%fa%' OR venue.street LIKE '%fa%' OR venue.city LIKE '%fa%' OR
venue.contactNumber LIKE '%fa%' OR venue.pointOfContact LIKE '%fa%' ORDER BY
venue.building ASC
Es funktioniert völlig in Ordnung, aber wenn ich hinzufügen, das Land (venue.country LIKE ‚% Suche % ') in wie es funktioniert nicht zum Beispiel
SELECT venue FROM X\application\model\entity\venue venue WHERE venue.building
LIKE '%fa%' OR venue.street LIKE '%fa%' OR venue.city LIKE '%fa%' OR
venue.contactNumber LIKE '%fa%' OR venue.pointOfContact LIKE '%fa%'
venue.country LIKE '%fa%' ORDER BY venue.building ASC
Kann mir jemand dabei helfen, ich bin mir sicher, dass Sie in reinem SQL innerlich beitreten, aber wie Sie in Doctrine tun. Danke für das Lesen der langen Frage. :)