Reputation: 332
SQL :
select distinct b.nom, b.moyenne_pond
from previ.rdt_usine b
join previ.rdt r on (r.id_us=b.id_us)
where st_intersects(st_transform(st_setsrid(st_makepoint(55.40513629386126, -21.23713970920021), 4326), 32740),b.geom)
and r.annee=2018;
PHP :
$query = 'select distinct "b.nom", "b.moyenne_pond"
from "previ"."'.$name_table.'" b
join "previ"."rdt" r on (r.id_us=b.id_us)
where st_intersects(st_transform(st_setsrid(st_makepoint(?, ?), 4326), 32740), b.geom)
and r.annee=?';
$data = $db->select($query, $coord);
//$coord is an array of data
When I tried to use my request I have a this : column "b.nom" doesn't exist
, but when I tried the query in pgAdmin the query is successfull, and you could see that the queries are exactly the same
Upvotes: 0
Views: 41
Reputation: 34914
Remove double quotes and add back tick
$query = 'select distinct `b.nom`, `b.moyenne_pond`
from `previ`.`$name_table` as b
join `previ`.`rdt` as r on (r.id_us=b.id_us)
where st_intersects(st_transform(st_setsrid(st_makepoint(?, ?), 4326), 32740), b.geom)
and r.annee=?';
Upvotes: 1