|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-04 03:08 UTC] marco dot we at gmx dot de
Description:
------------
Hello,
i'm trying to insert a text from a file into a informix database.
Reproduce code:
---------------
<?php
$sProblemtitel = 'Titeltext';
$stmt = $db->prepare( 'INSERT INTO meldung ( problem_kurz, hist_aktion ) VALUES ( roblem_kurz, :hist_aktion )' );
$stmt->bindParam( 'problem_kurz', $sProblemtitel,PDO::PARAM_STR );
$fp = fopen("temp.tmp", 'rb');
$stmt->bindParam( 'hist_aktion', $fp, PDO::PARAM_LOB );
$stmt->execute();
?>
Expected result:
----------------
No error
Actual result:
--------------
SQLSTATE[HY000]: General error: -608 [Informix][Informix ODBC Driver][Informix]Illegal attempt to convert Text/Byte blob type. (SQLParamData[-608] at ..\pecl\pdo_informix\informix_statement.c:788)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Hello, thank you for your fast response. I've tried the examplecode from the latest package: /* Drop the test table, in case it exists */ $drop = 'DROP TABLE animals'; $result = self::getInstance()->exec( $drop ); /* Create the test table */ $server_info = self::getInstance()->getAttribute(PDO::ATTR_SERVER_INFO); $create = 'CREATE TABLE animals (id INTEGER, my_clob text, my_blob byte)'; $res = self::getInstance()->exec( $create ); $stmt = self::getInstance()->prepare('insert into animals (id,my_clob,my_blob) values (:id,:my_clob,:my_blob)'); $clob = "test clob data\n"; $blob = "test blob data\n"; print "inserting from php variable\n"; $stmt->bindValue( ':id' , 0 ); $stmt->bindParam( ':my_clob' , $clob , PDO::PARAM_LOB , strlen($clob) ); $stmt->bindParam( ':my_blob' , $blob , PDO::PARAM_LOB , strlen($blob) ); $stmt->execute(); but the error is the same. For notice i'm using the latest xampp in version 1.7.0 where the php_pdo_informix.dll is from version 1.2.5. Do you need further informations?Now i've tried the test from inserting data from an filestream. print "inserting from php file stream<br>"; $fp1 = fopen( dirname(__FILE__) . "/clob.dat" , "rb" ); $fp2 = fopen( dirname(__FILE__) . "/spook.png" , "rb" ); $stmt = $this->db->prepare('insert into animals (id,my_clob,my_blob) values (:id,:my_clob,:my_blob)'); $stmt->bindValue( ':id' , 1 ); $stmt->bindParam( ':my_clob' , $fp1 , PDO::PARAM_LOB ); $stmt->bindParam( ':my_blob' , $fp2 , PDO::PARAM_LOB ); $stmt->execute(); This will give the following error: 'SQLSTATE[22001]: String data, right truncated: -11023 [Informix][Informix ODBC Driver]String data right truncation. (SQLPutData[-11023] at ..\pecl\pdo_informix\informix_statement.c:790)'