4

i am using https://github.com/djlambert/doctrine2-spatial and i have an error when trying a query with the "contains" function

firstly, if i put this :

dql:
    numeric_functions:
       Contains:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Contains

under orm like in doc (https://github.com/djlambert/doctrine2-spatial/blob/master/INSTALL.md), i have this error :

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "dql" under "doctrine.orm"

but if i put it under doctrine.orm.entity_managers.default there is no error but i still have an error when running the query, here is my code :

$sql = 'SELECT DemoTadBundle:DeliveryZone dz WHERE Contains(dz.area, :point)'; //dz.area is of type polygon
$converter = new SpatialConverter();
$q = $this->_em->createQuery($sql)->setParameter('point', $converter->convertToDatabaseValue($address->getPoint())); //$address->getPoint returns an CrEOF\Spatial\PHP\Types\Geometry\Point object
return $q->getOneOrNullResult();

and here is the error :

[Semantical Error] line 0, col 41 near 'Contains(dz.area,': Error: Class 'Contains' is not defined.

can someone help me to resolve this problem ?

my symfony version is 2.5

thank you.

Naeh
  • 119
  • 7
  • have You found solution? I get the same error "Unrecognized options "dql" under "doctrine.orm" " – mmmm Oct 15 '14 at 09:22
  • Hello Mati, it seems that i was mixing the short syntax and the complete syntax, i will answer with the entire config file – Naeh Oct 15 '14 at 09:33
  • @Naeh the `SpatialConverter` is no more available in the master branch of the branch. So which branch are you using now? – Amine Jallouli Mar 22 '16 at 14:15

2 Answers2

3

i resolved my problem, it seems that i was mixing the short and the complete syntax, here is my entire config.yml file (only the doctrine section)

i hope this will help :)

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        types:
            geometry:   CrEOF\Spatial\DBAL\Types\GeometryType
            point:      CrEOF\Spatial\DBAL\Types\Geometry\PointType
            polygon:    CrEOF\Spatial\DBAL\Types\Geometry\PolygonType
            linestring: CrEOF\Spatial\DBAL\Types\Geometry\LineStringType
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                dql:
                    numeric_functions:
                        Contains: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Contains
                        AsText: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\AsText
                        AsBinary: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\AsBinary
                        GeomFromText: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GeomFromText

                auto_mapping: true
                mappings:
                    gedmo_tree:
                        type:       annotation
                        prefix:     Gedmo\Tree\Entity
                        dir:        "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                        alias:      GedmoTree # this one is optional and will default to the name set for the mapping
                        is_bundle:  false
Naeh
  • 119
  • 7
0

This may be a problem with your config file and that your spacing may be incorrect. Pay very close attention to make sure all of the indents are proper and that dql is indented after orm, and orm lines up with dbal.

George
  • 1,478
  • 17
  • 28