I am coding a website using CodeIgniter 2 as my framework, and recently I started using Doctrine 2 for ORM.
My database needs to store spatial data (such as a dot column), and apparently Doctrine cannot handle this out of the box.
I searched all over the internet and found only these tips: http://codeutopia.net/blog/2011/02/19/using-spatial-data-in-doctrine-2/
But this article is unclear where to save these files and what else needs to be configured. I tried to contact the author and never heard.
Can anyone help?
Thank! Ryan
, , 4 CodeIgniter/application/libraries/Doctrine/CustomAddon:
"CustomAddon".
CodeIgniter/application/libraries/Doctrine.php :
require_once APPPATH . 'libraries/Doctrine/CustomAddon/Distance.php'; require_once APPPATH . 'libraries/Doctrine/CustomAddon/Point.php'; require_once APPPATH . 'libraries/Doctrine/CustomAddon/PointStr.php'; require_once APPPATH . 'libraries/Doctrine/CustomAddon/PointType.php'; Doctrine\DBAL\Types\Type::addType('point', 'CustomAddon\PointType'); //Assuming $config is a Doctrine\ORM\Configuration object used to configure the EM $config->addCustomNumericFunction('DISTANCE', 'CustomAddon\Distance'); $config->addCustomNumericFunction('POINT_STR', 'CustomAddon\PointStr'); // Create EntityManager $this->em = EntityManager::create($connectionOptions, $config);
:
$point = new \CustomAddon\Point($geo['lat'], $geo['lon']);
1.2, , . 1.2.4 yaml , . , , :
$phone->point = new Doctrine_Expression("GEOMFROMTEXT('POINT(25 10)')");
, 25 10, . 1.2.4 . , select:
$query = Doctrine_Query::create() ->select ('X(p.point), Y(p.point)') ->from('Points p');
, (x y) . , 1.2.4, , - 2. !