データベースに接続するときにこの問題が発生します。PDOを使用して、Postgresで実行するサブクエリを含むクエリを作成しようとしています。残念ながら、「無効なパラメーター番号: :sensor」が表示されます
$statement="select di_timestamp, di_item_value
from data_item
where
fk_fc_id=(select fc_id
from field_column
where
fc_description is like ':sensor'
and
fk_mds_id=( select mds_id
from monitored_data_set
where fk_pa_id=(select pa_id
from pilot_ambient
where
pa_ambient_name ilike ':room'
and
fk_sp_id=(
select sp_id
from School_Pilot
where sp_description ilike '%:name%'
)
)
)
)";
$query = $databaseConn->prepare($statement);
$query->execute(array(':sensor'=>'Room Temperature',':room'=>'rm1',':name' => 'school1'));
私の問題は、:(item) を囲む ' 文字のエスケープによるものだと思います。\ を使用してみましたが、構文エラーが発生します。PHPが文字列を正常に置換し、Postgresでエラーを引き起こさないという、私が知らない慣習があると思います。
これを見てくれてありがとう、ジェームズ