我在啓用PostGIS的Postgre數據庫上使用Symfony和Doctrine2。我有兩個表 - 財產和鄰里有以下結構:編寫Doctrine2查詢以加入兩個空間表
class Property {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $address;
/**
* @var Point $geom
* @ORM\Column(type="Point", nullable=true)
*/
protected $geom;
}
class Neighborhood {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $gid;
/**
* @ORM\Column(type="string")
*/
protected $name;
/**
* @ORM\Column(type="string")
*/
protected $description;
/**
* @var Polygon $geom
*
* @ORM\Column(type="Polygon", nullable=true)
*/
protected $geom;
}
在pgAdminIII,我可以寫下面的查詢工作正常:
SELECT address, neighborhood.name
FROM property
JOIN neighborhood
ON ST_Contains(neighborhood.geom, property.geom)
我怎麼能寫這篇文章DQL?我理解連接的基礎知識併爲Doctrine2映射添加註釋,但我不確定如何執行連接,因爲兩個字段不相等。我需要使用ST_Contains函數來創建連接。 我正在使用djlambert/doctrine2-spatial束進行空間數據類型和映射。我能夠單獨查詢每個表,並在每個表上創建地圖,但不知道如何選擇給定鄰域中的所有屬性。
在我的配置文件中,我有點映射到點 'mapping_types:point:Point' – George