如何在 PHP UPDATE 查询中引用 Imagick 对象?
这个查询有什么问题?
我正在尝试将 ImageMagick 对象写回数据库(PostgreSQL bytea 字段)。 这是 PHP 代码 - 使用 Imagick 函数。
$query = "UPDATE table SET destcol = ".$im." WHERE key = " .$args[0];
What is wrong with this query?
Am trying to write an ImageMagick object back into a database (a PostgreSQL bytea field).
This is PHP code - using the Imagick functions.
$query = "UPDATE table SET destcol = ".$im." WHERE key = " .$args[0];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
$im
是来自执行操作,那么您的查询将会失败。您不能像这样将 PHP 对象插入到数据库中。至少,您必须执行类似的操作
还要注意,这很可能会失败 - 如果对象在内部保存打开的文件,那么一旦将对象从数据库中拉出并取消序列化()',这些文件句柄几乎肯定会无效d.
为什么需要以这种方式保存一个 imagick 对象?首先实例化它的成本并不高。
If that
$im
is from doingyour query will fail. You cannot insert a PHP object into a database like that. At bare mininum, you must do something like
Also note that this will most likely fail - if the object is holding open files internally, those file handles will almost certainly not be valid once the object is pulled out of the database and unserialize()'d.
Why do you need to preserve an imagick object in this fashion? The cost of instantiating it in the first place is not exactly high.
我猜测您正在更新字符串列而不引用它们。
I'm going to guess that you're updating string columns without quoting them.;