php - Laravel Postgis generate Point object -


i developing system laravel framework using postgres database postgis. database has table geometry field (3d point). need convert 3 dimensions point object , point objects 3 dimensions.

i searched laravel postgis library , found laravel-postgis, developed 2d point , has no support 3d points. therefore decided use directly or develop convert function in php using in laravel.

some code tried insert new data directly :

$arr = ['geometry' => "st_pointfromtext('point(' || " . input::get('latitude') . " || ' ' || " . input::get('longitude') . " || ' ' || " . input::get('altitude') . " || ')', 4326)"]; location::where('id','1')->update($arr); 

the sample initialize of $arr variable

st_pointfromtext('point(' || 1 || ' ' || 1 || ' ' || 1 || ')', 4326)

it's found in this link

but laravel debug got errors me :

pdoexception in connection.php line 384: sqlstate[xx000]: internal error: 7 error: parse error - invalid geometry hint: "st" <-- parse error @ position 2 within geometry  sqlstate[xx000]: internal error: 7 error: parse error - invalid geometry hint: "st" <-- parse error @ position 2 within geometry (sql: update "dblocation" set "geometry" = st_pointfromtext('point(' || 1 || ' ' || 1 || ' ' || 1 || ')', 4326) "id" = 1) 

i want know mistake.

i'm not sure syntax of parametrized queries, should this:

st_setsrid(st_makepoint(%, %, %), 4326); 

with 3 parameters: longitude, latitude, altitude in order!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -