Created
February 8, 2021 17:27
-
-
Save BenMorel/d88fb4411a3c0fbd924df7def2d94074 to your computer and use it in GitHub Desktop.
Attempt to reproduce https://github.com/brick/geo/issues/21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"doctrine/orm": "^2.8", | |
"brick/geo": "^0.4.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE User ( | |
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, | |
location POINT NOT NULL | |
); | |
INSERT INTO User (location) VALUES(ST_GeomFromText('POINT(1 1)')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Brick\Geo; | |
use Brick\Geo\Point; | |
use Doctrine\DBAL\DriverManager; | |
use Doctrine\DBAL\Types\Type; | |
use Doctrine\ORM\Configuration; | |
use Doctrine\ORM\EntityManager; | |
use Doctrine\ORM\Mapping as ORM; | |
use Foodbox\Configuration\AppConfiguration; | |
/** | |
* @ORM\Entity | |
*/ | |
class User | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue | |
*/ | |
private int $id; | |
/** | |
* @ORM\Column(type="Point") | |
*/ | |
private Point $location; | |
} | |
require __DIR__ . '/vendor/autoload.php'; | |
Type::addType('Point', Geo\Doctrine\Types\PointType::class); | |
$connection = DriverManager::getConnection([ | |
'driver' => 'pdo_mysql', | |
'host' => 'localhost', | |
'user' => 'root', | |
'password' => '', | |
'dbname' => 'test' | |
]); | |
$config = new Configuration(); | |
$config->setMetadataDriverImpl( | |
$config->newDefaultAnnotationDriver('.', false) | |
); | |
$config->setProxyDir(__DIR__); | |
$config->setProxyNamespace('App\Proxy'); | |
$em = EntityManager::create($connection, $config); | |
var_dump($em->find(User::class, 1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment