使用ADOdb库通过oracle数据库后端使用php上传图像
读取图像的代码行是
$regular = fread(fopen('tmp/tmp3.jpg', "r"), filesize('tmp/tmp3.jpg'));
$thumb= fread(fopen('tmp/tmp2.jpg', "r"), filesize('tmp/tmp2.jpg'));
$pure = fread(fopen('tmp/tmp.jpg', "r"), filesize('tmp/tmp.jpg'));
这是我应该将图像插入数据库的代码。
$q = "INSERT INTO pacs_images VALUES (:record_id, :image_id, :thumb, :regular, :pure)";//debug
$statement = $conn -> Prepare($q);
$rs = $conn -> Execute($statement, array('record_id' => $fileNumber, 'image_id' => $imageNumber,
'thumb' => $thumb, 'regular' => $regular, 'pure' => $pure));
我从 Oracle 得到的错误消息是
ORA-01461: can bind a LONG value only for insert into a LONG column
我知道表模式是
Name Null? Type
----------------------------------------- -------- ----------------------------
RECORD_ID NOT NULL NUMBER(38)
IMAGE_ID NOT NULL NUMBER(38)
THUMBNAIL BLOB
REGULAR_SIZE BLOB
FULL_SIZE BLOB
我不知道这里出了什么问题,我很确定数据库模式设置正确并且 $fileNumber 和 $imageNumber 是整数,并且我已经回应了他们,并确保他们打印了正确的数字,在本例中是 1001。我还使用 oci8 驱动程序连接到 Oracle。谁能看出这段代码有什么问题吗?
The lines of code that reads the images are
$regular = fread(fopen('tmp/tmp3.jpg', "r"), filesize('tmp/tmp3.jpg'));
$thumb= fread(fopen('tmp/tmp2.jpg', "r"), filesize('tmp/tmp2.jpg'));
$pure = fread(fopen('tmp/tmp.jpg', "r"), filesize('tmp/tmp.jpg'));
This is the code I have that should insert an image into the database.
$q = "INSERT INTO pacs_images VALUES (:record_id, :image_id, :thumb, :regular, :pure)";//debug
$statement = $conn -> Prepare($q);
$rs = $conn -> Execute($statement, array('record_id' => $fileNumber, 'image_id' => $imageNumber,
'thumb' => $thumb, 'regular' => $regular, 'pure' => $pure));
The error message I get from oracle is
ORA-01461: can bind a LONG value only for insert into a LONG column
I know for the fact that the table schema is
Name Null? Type
----------------------------------------- -------- ----------------------------
RECORD_ID NOT NULL NUMBER(38)
IMAGE_ID NOT NULL NUMBER(38)
THUMBNAIL BLOB
REGULAR_SIZE BLOB
FULL_SIZE BLOB
I don't know what is wrong here, I'm pretty sure the database schema is set up properly and $fileNumber and $imageNumber are integers, and I have echoed them and made sure they are printing the right numbers, in this case, 1001. I'm also using the oci8 driver to connect to oracle. Can anyone see what's wrong with this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 ADOdb 中找到了执行此操作的实际方法,
因此您需要放入一个empty_blob(),然后更新它。
Found the actual way to do it in ADOdb
So you need to put in an empty_blob(), and then update it.
编辑:这不是正确的答案,请参阅其他答案。
听起来它认为 $regular、$thumb 等都是多头。
根据PHP Oracle FAQ的代码插入blob 应该如下所示:
我的猜测是您需要在该特定名称上设置 OCI_B_BLOB。
EDIT: This is not the right answer, see the other answer.
Sounds like it thinks that $regular, $thumb, etc. are longs.
According to the PHP Oracle FAQ the code to insert a blob should look like:
My guess is you need the OCI_B_BLOB set on that specific name.
根据 Glens 的回答,使用 Oracle 12c,您现在可以使用自动序列更快/自动地完成此操作。
According to Glens answer, with Oracle 12c you can do it now faster/automatic with an Auto Sequence.