@@ -1494,7 +1494,11 @@ public function find(Document $collection, array $queries = [], ?int $limit = 25
14941494 $ stmt = $ this ->getPDO ()->prepare ($ sql );
14951495
14961496 foreach ($ binds as $ key => $ value ) {
1497- $ stmt ->bindValue ($ key , $ value , $ this ->getPDOType ($ value ));
1497+ if (gettype ($ value ) === 'double ' ) {
1498+ $ stmt ->bindValue ($ key , $ this ->getFloatPrecision ($ value ), PDO ::PARAM_STR );
1499+ } else {
1500+ $ stmt ->bindValue ($ key , $ value , $ this ->getPDOType ($ value ));
1501+ }
14981502 }
14991503
15001504 $ stmt ->execute ();
@@ -1711,13 +1715,13 @@ protected function handleSpatialQueries(Query $query, array &$binds, string $att
17111715 $ distanceParams = $ query ->getValues ()[0 ];
17121716 $ binds [": {$ placeholder }_0 " ] = $ this ->convertArrayToWKT ($ distanceParams [0 ]);
17131717 $ binds [": {$ placeholder }_1 " ] = $ distanceParams [1 ];
1714- return "ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) < = : {$ placeholder }_1 " ;
1718+ return "ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) = : {$ placeholder }_1 " ;
17151719
17161720 case Query::TYPE_NOT_DISTANCE :
17171721 $ distanceParams = $ query ->getValues ()[0 ];
17181722 $ binds [": {$ placeholder }_0 " ] = $ this ->convertArrayToWKT ($ distanceParams [0 ]);
17191723 $ binds [": {$ placeholder }_1 " ] = $ distanceParams [1 ];
1720- return "ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) > : {$ placeholder }_1 " ;
1724+ return "ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) != : {$ placeholder }_1 " ;
17211725
17221726 case Query::TYPE_DISTANCE_GREATER_THAN :
17231727 $ distanceParams = $ query ->getValues ()[0 ];
@@ -1731,18 +1735,6 @@ protected function handleSpatialQueries(Query $query, array &$binds, string $att
17311735 $ binds [": {$ placeholder }_1 " ] = $ distanceParams [1 ];
17321736 return "ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) < : {$ placeholder }_1 " ;
17331737
1734- case Query::TYPE_NOT_DISTANCE_GREATER_THAN :
1735- $ distanceParams = $ query ->getValues ()[0 ];
1736- $ binds [": {$ placeholder }_0 " ] = $ this ->convertArrayToWKT ($ distanceParams [0 ]);
1737- $ binds [": {$ placeholder }_1 " ] = $ distanceParams [1 ];
1738- return "NOT (ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) > : {$ placeholder }_1) " ;
1739-
1740- case Query::TYPE_NOT_DISTANCE_LESS_THAN :
1741- $ distanceParams = $ query ->getValues ()[0 ];
1742- $ binds [": {$ placeholder }_0 " ] = $ this ->convertArrayToWKT ($ distanceParams [0 ]);
1743- $ binds [": {$ placeholder }_1 " ] = $ distanceParams [1 ];
1744- return "NOT (ST_Distance( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) < : {$ placeholder }_1) " ;
1745-
17461738 case Query::TYPE_INTERSECTS :
17471739 $ binds [": {$ placeholder }_0 " ] = $ this ->convertArrayToWKT ($ query ->getValues ()[0 ]);
17481740 return "ST_Intersects( {$ alias }. {$ attribute }, ST_GeomFromText(: {$ placeholder }_0)) " ;
@@ -1978,13 +1970,24 @@ protected function getSQLType(string $type, int $size, bool $signed = true, bool
19781970 protected function getPDOType (mixed $ value ): int
19791971 {
19801972 return match (gettype ($ value )) {
1981- 'double ' , ' string ' => PDO ::PARAM_STR ,
1973+ 'string ' => PDO ::PARAM_STR ,
19821974 'integer ' , 'boolean ' => PDO ::PARAM_INT ,
19831975 'NULL ' => PDO ::PARAM_NULL ,
19841976 default => throw new DatabaseException ('Unknown PDO Type for ' . \gettype ($ value )),
19851977 };
19861978 }
19871979
1980+ /**
1981+ * Size of POINT spatial type
1982+ *
1983+ * @return int
1984+ */
1985+ protected function getMaxPointSize (): int
1986+ {
1987+ // https://dev.mysql.com/doc/refman/8.4/en/gis-data-formats.html#gis-internal-format
1988+ return 25 ;
1989+ }
1990+
19881991 public function getMinDateTime (): \DateTime
19891992 {
19901993 return new \DateTime ('1000-01-01 00:00:00 ' );
0 commit comments