Bind BYTEA to PGSQL PDO Prepared Statement in PHP5

拥有回忆 提交于 2020-01-14 12:33:15

问题


I cannot seem to find a way to bind a bytea to a prepared statement using PHP5's PDO and PostgreSQL. Heres how i imagine this working...

$this->stmtPDO = $this->hPDO->prepare (
    'INSERT INTO board.feedback ("created", "title", "payloaddata")
     VALUES (NOW(), :title, :payload) RETURNING psk;', 
    array(PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL)
);
$this->stmtPDO->bindParam(":payload", $payload);
$this->stmtPDO->bindParam(":title", $title);
$this->stmtPDO->execute();

Has anyone found an easy solution for this?


回答1:


Have you tried to set the type of the parameter to PDO::PARAM_LOB? E.g.

$this->stmtPDO->bindParam(":payload", $payload, PDO::PARAM_LOB);?


来源:https://stackoverflow.com/questions/5313066/bind-bytea-to-pgsql-pdo-prepared-statement-in-php5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!