-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgravar.php
More file actions
25 lines (21 loc) · 905 Bytes
/
Copy pathgravar.php
File metadata and controls
25 lines (21 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
$nome = $_POST['nome'];
$criador = $_POST['criador'];
$dias = $_POST['dias'];
$hora = $_POST['hora'];
$linestring = $_POST['linestring'];
$linestring = str_replace(',',' ', $linestring);
$linestring = str_replace('] [',',', $linestring);
$linestring = str_replace('[','', $linestring);
$linestring = str_replace(']','', $linestring);
// Connecting, selecting database
$dbconn = pg_connect("host=localhost dbname=FACEBIKE user=postgres password=123456")
or die('Could not connect: ' . pg_last_error());
// Performing SQL query
//$query = 'SELECT ST_AsText(caminho) as caminho FROM rotas';
$query = "INSERT INTO rotas (nome, dias, horario, criador, caminho) VALUES('$nome', '$dias', '$hora', '$criador', ST_GeomFromText('LINESTRING($linestring)', 3857))";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
echo 'success';
//// Closing connection
pg_close($dbconn);
?>