次の作業を行うことができません。以下の例でプリペアド ステートメントを使用したいのですが、エラーが発生します。関数は間違いなく正しい値を $array に渡します:
private function getInfoFromSystem($array) {
try {
$sql = "
SELECT
PCO_AGENT.NAME,
PCO_INBOUNDLOG.LOGIN AS LOGINID,
PCO_INBOUNDLOG.PHONE AS CALLERID,
PCO_INBOUNDLOG.STATION AS EXTEN,
PCO_INBOUNDLOG.TALKTIME AS CALLLENGTH,
PCO_INBOUNDLOG.CHANNELRECORDID AS RECORDINGID,
PCO_SOFTPHONECALLLOG.RDATE,
PCO_INBOUNDLOG.RDATE AS INBOUNDDATE
FROM
PCO_INBOUNDLOG
INNER JOIN
PCO_LOGINAGENT ON PCO_INBOUNDLOG.LOGIN = PCO_LOGINAGENT.LOGIN
INNER JOIN
PCO_SOFTPHONECALLLOG ON PCO_INBOUNDLOG.ID = PCO_SOFTPHONECALLLOG.CONTACTID
INNER JOIN
PCO_AGENT ON PCO_LOGINAGENT.AGENTID = PCO_AGENT.ID
WHERE
LOGINID = :extension
";
$arr = array(":extension" => $array['extension']);
$query = $this->mssql->prepare($sql);
$query->execute($arr);
// $sql = "select * from sys.messages where message_id = 229";
foreach($this->mssql->query($sql) as $row) {
echo "<pre>";
print_r($row);
echo "</pre>";
}
}
catch(PDOException $e) {
echo $e->getMessage();
}
}