Php Yii无法在postgreSQL数据库表中插入带空格的字符串

Php Yii无法在postgreSQL数据库表中插入带空格的字符串,php,postgresql,yii,pdo,Php,Postgresql,Yii,Pdo,我正在使用PDO将值插入postgreSQL数据库。我正在尝试将文件路径插入表中。问题是,当文件名包含空间时,它会将部分文件名插入到空间中。 下面是代码 $command = Yii::app()->db->createCommand("select * from sp_email_attachment_insert(:message_id,:attachment_url);"); $command->bindParam(":message_id",$this->mess

我正在使用PDO将值插入postgreSQL数据库。我正在尝试将文件路径插入表中。问题是,当文件名包含空间时,它会将部分文件名插入到空间中。 下面是代码

$command = Yii::app()->db->createCommand("select * from sp_email_attachment_insert(:message_id,:attachment_url);");
$command->bindParam(":message_id",$this->message_id,PDO::PARAM_STR);
$command->bindParam(":attachment_url",$this->attachment_url,PDO::PARAM_STR);
$result=$command->queryAll();
下面是postgreSQL函数

CREATE OR REPLACE FUNCTION sp_email_attachment_insert(_message_id integer, _attachment character varying)
  RETURNS void AS
$BODY$

BEGIN

INSERT INTO message_attachment(message_id,attachment) VALUES(_message_id,_attachment);

exception when others then 
    raise exception '% %', SQLERRM, SQLSTATE;
END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION sp_email_attachment_insert(integer, character varying)
  OWNER TO postgres;

请帮忙。提前谢谢

您是否检查了值“$this->attachment\u url”以确保其正确性?您能否向我们展示函数sp_email_attachment_insert()以了解发生了什么?如果我正确理解了您的问题,您可以使用serialize(插入/更新时)和unserialize(选择时)来避免断开字符串@“$this->attachment\u url”中的FrankHeikens值正确。我已经更新了问题。列附件使用什么类型?如果是(例如)VARCHAR(10),任何长度超过10个字符的输入都将被截断。(根据规范,标准SQL行为)。手动使用时,功能是否正常工作?(使用pgAdmin或其他客户端)@FrankHeikens抱歉。问题不在于PDO。它位于用于显示附件的jquery中。