Skip to content

Error occurs when saving a point - "Incorrect parameter count in the call to native function 'ST_GeomFromText'" #138

Open
@Art-Mas

Description

@Art-Mas

Hi! I decided to try your package in PHPUnit:

$point = new Point();
$point->point = new \Grimzy\LaravelMysqlSpatial\Types\Point(40.7484404, -73.9878441);
$point->save(); 

an error occurs when running the test:

SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function 'ST_GeomFromText' (SQL: insert into points (point) values (ST_GeomFromText(POINT(-73.9878441 40.7484404), 0, 'axis-order=long-lat'))

but if you delete the line ", 'axis-order=long-lat' " in the file SpatialExpression.php then saving will work fine, see screenshot:
image

I also tried running the raw query leaving the string ", 'axis-order=long-lat' " and it worked without an error:

DB::insert(
    "insert into `points` (`point`) values (ST_GeomFromText('POINT(-73.9878441 40.7484404), 0, axis-order=long-lat'))"
);

Please help :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions