|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-02-04 08:46 UTC] matthias dot djihangiroff at persona dot de
Description:
------------
The PHP-Version is: 5.2.3
If i start a prepare with more than one paramater (?), the sql does nothing.
The same code is running fine on a open SuSE 10.3 with a PDO-INFORMIX 1.0.
Reproduce code:
---------------
$db = new PDO('informix:host=host; service=1528; database=database; server=tcp_server; protocol=onsoctcp; EnableScrollableCursors=1;TRANSLATIONDLL=/opt/informix/lib/esql/igo4a304.so');
$stmt = $db->prepare("INSERT INTO table (mandant, nlnr, rechnungsnr, kundennr, rechnungsdat, fakturamon, auftragsnr, kundenname, referenznr, kennzeichen, rechnungspdf)
VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1, $data[0]);
$stmt->bindParam(2, $data[1]);
$stmt->bindParam(3, $data[2]);
$stmt->bindParam(4, $data[3]);
$stmt->bindParam(5, $data[4]);
$stmt->bindParam(6, $data[5]);
$stmt->bindParam(7, $data[6]);
$stmt->bindParam(8, $data[7]);
$stmt->bindParam(9, $data[8]);
$stmt->bindParam(10, $data[9]);
$stmt->bindParam(11, $fp, PDO::PARAM_LOB);
$stmt->execute();
Expected result:
----------------
Ive expect, that a file is put into the database as blob
Actual result:
--------------
The SQL doesnt insert anything.
A backtrace is: SQLParamData[0] at /tmp/pear/cache/PDO_INFORMIX-1.1.0/informix_statement.c:783
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
Hi, The following works for me: <?php require_once('fvt.inc'); class Test extends FVTTest { public function runTest() { $this->connect(); try { /* Drop the test table, in case it exists */ $drop = 'DROP TABLE animals'; $result = $this->db->exec( $drop ); } catch( Exception $e ){} /* Create the test table */ $create = 'CREATE TABLE animals (id INTEGER, my_clob clob)'; $result = $this->db->exec( $create ); $fp = fopen( dirname(__FILE__) . "/large_clob.dat" , "r" ); $stmt = $this->db->prepare('insert into animals (id, my_clob) values (?, ?)'); print "inserting from file stream\n"; $zero = 0; $stmt->bindParam( 1, $zero ); $stmt->bindParam( 2 , $fp , PDO::PARAM_LOB ); $stmt->execute(); print "succesful\n"; print "runnign query\n"; $stmt = $this->db->prepare( 'select id, my_clob from animals' ); $stmt->bindColumn( 'ID' , $id ); $stmt->bindColumn( 'MY_CLOB' , $clob , PDO::PARAM_LOB ); $rs = $stmt->execute(); while ($stmt->fetch(PDO::FETCH_BOUND)) { var_dump( $id ); var_dump( $clob ); } print "done\n"; } } $testcase = new Test(); $testcase->runTest(); ?> Do you have a test case I can use to re-create this issue? Also, please update to the latest version of PDO_INFORMIX and check if you still get an error. Thanks.Hi, Please make sure that you are setting the DBDATE variable on the machine where the CSDK is installed. I have tried to re-create this issue and the following works: <?php require_once('fvt.inc'); class Test extends FVTTest { public function runTest() { $this->connect(); try { /* Drop the test table, in case it exists */ $drop = 'DROP TABLE animals'; $result = $this->db->exec( $drop ); } catch( Exception $e ){} /* Create the test table */ $create = 'CREATE TABLE animals (id INTEGER, a_date DATE)'; $result = $this->db->exec( $create ); $stmt = $this->db->prepare('insert into animals (id, a_date) values (?, ?)'); print "inserting from file stream\n"; $zero = 0; $a_date = '14.03.2008'; $stmt->bindParam( 1, $zero ); $stmt->bindParam( 2, $a_date ); $stmt->execute(); print "succesful\n"; print "runnign query\n"; $stmt = $this->db->prepare( 'select id, a_date from animals' ); $stmt->bindColumn( 'ID' , $id ); $stmt->bindColumn( 'A_DATE' , $b_date ); $rs = $stmt->execute(); while ($stmt->fetch(PDO::FETCH_BOUND)) { var_dump( $id ); var_dump( $b_date ); } print "done\n"; } } $testcase = new Test(); $testcase->runTest(); ?> If it still does not work please provide a test case. Thanks.This is my test case. dbschema: { TABLE "informix".leps row size = 204 number of columns = 8 index size = 30 } create table "informix".leps ( dokkey serial not null , mandant char(3) not null , nlnr char(4) not null , persnr char(8) not null , abrechdat date not null , lohn char(7), lohnpdf "informix".clob, name char(100) not null ); revoke all on "informix".leps from "public"; create unique index "informix".ixkunstl2 on "informix".leps (dokkey) using btree ; create unique index "informix".ixrow2 on "informix".leps (nlnr, persnr,abrechdat) using btree ; PHP-Source: session_start(); $session = session_id(); ini_set("error_reporting",E_ALL); try { $db = new PDO('informix:host=primergy.konzern.intern; service=1528; database=pdfarchiv; server=tcp_primergy; protocol=onsoctcp; TRANSLATIONDLL=/opt/informix/lib/esql/igo4a304.so'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $var = '123456'; $monat = '10.01.2007'; //$monat = '2007-01-10'; $mandant = 'PS'; $stmt = $db->prepare("SELECT lohnpdf FROM leps WHERE persnr=? AND abrechdat =? AND mandant=?"); $stmt->bindParam(1, $var); $stmt->bindParam(2, $monat); $stmt->bindParam(3, $mandant); $stmt->execute(); $stmt->bindColumn(1, $lob, PDO::PARAM_LOB); $stmt->fetch(PDO::FETCH_BOUND); header("Content-type: application/pdf"); header("Content-Transfer-Encoding: binary"); fpassthru($lob); } catch (PDOException $error) { Echo "SQL-Error: " . $error->getMessage(); //print_r($stmt->errorInfo()); exit; } If you switch $monat from '2007-01-10' to '10.01.2007', i get the following error: SQL-Error: SQLSTATE[22018]: Invalid character value for cast specification: -11106 [Informix][Informix ODBC Driver]Invalid character value for cast specification. (SQLExecute[4294956190] at /tmp/pear/cache/PDO_INFORMIX-1.2.0/informix_statement.c:730)One note: If i do an insert with a german date format (DMY4.) but without a blob on a table with a blob, the IDS Instance Crashes without any note in the online.log Code: $date = '01.03.2008'; $stmt = $db->prepare("INSERT INTO leps (mandant, nlnr, persnr, abrechdat, name) VALUES (?,?,?,?,?)"); $stmt->bindParam(4, $date); If i use english formats, with and without the blob column in the insert sql, all is running fine. $date = '2008-03-01'; $stmt = $db->prepare("INSERT INTO leps (mandant, nlnr, persnr, abrechdat, name, blob) VALUES (?,?,?,?,?,?)"); $stmt->bindParam(4, $date);