4

https://github.com/djlambert/doctrine2-spatialを使用していますが、「contains」関数でクエリを実行しようとするとエラーが発生します

まず、これを置くと:

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

ドキュメント( https://github.com/djlambert/doctrine2-spatial/blob/master/INSTALL.md )のようにormの下で、私はこのエラーがあります:

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

しかし、それを doctrine.orm.entity_managers.default の下に置くと、エラーはありませんが、クエリの実行時にまだエラーが発生します。これが私のコードです:

$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();

ここにエラーがあります:

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

誰かがこの問題を解決するのを手伝ってくれますか?

私のsymfonyのバージョンは2.5です

ありがとうございました。

4

2 に答える 2

3

問題を解決しました。短い構文と完全な構文を混在させていたようです。ここにconfig.ymlファイル全体を示します(教義セクションのみ)

これが役立つことを願っています:)

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
于 2014-10-15T09:38:05.320 に答える