php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58026 Prepare with more than one Parameter
Submitted: 2008-02-04 08:46 UTC Modified: 2010-12-15 04:11 UTC
From: matthias dot djihangiroff at persona dot de Assigned:
Status: Closed Package: PDO_INFORMIX (PECL)
PHP Version: 5.2.5 OS: OpenSuSE 10.3 x64
Private report: No CVE-ID: None
 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-05 02:35 UTC] matthias dot djihangiroff at persona dot de
Sorry, the PHP-Version is 5.2.5
 [2008-03-13 18:06 UTC] opendev at us dot ibm dot com
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.
 [2008-03-14 02:38 UTC] matthias dot djihangiroff at persona dot de
It works with correct error statements now.
But it doesnt recognize german Date formats.

DBDATE is DMY4.

If i use '14.03.2008' it doesnt work.
If i use '2008-03-14' it work.
 [2008-03-14 11:59 UTC] opendev at us dot ibm dot com
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.
 [2008-03-31 08:28 UTC] m dot djihangiroff at persona dot de
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)
 [2008-04-02 04:40 UTC] opendev at us dot ibm dot com
Hi..

We are currently looking into it. Would get back to you ASAP. Thanks for the bug report. Meanwhile it would be helpful to know the IDS version being used.
 [2008-04-02 04:43 UTC] matthias dot djihangiroff at persona dot de
IBM Informix Dynamic Server Version 10.00.FC6
 [2008-04-04 06:03 UTC] opendev at us dot ibm dot com
Hi..

The problem is supposedly with CSDK and not PDO-Informix. I have been able to run the code successfully on CSDK version 2.90 with Suse. We are trying to delve further into the problem and would let you know the status soon. Can you tell me the CSDK version you are using?? To know the CSDK version run "esql -V". Or can you try installing CSDK version 2.9 on your machine and check. 

Please note that if the format is any other than Y4MD-, you need to do an "export DBDATE=format" before execution of code.

Regards
 [2008-04-04 06:11 UTC] matthias dot djihangiroff at persona dot de
# esql -V
IBM Informix CSDK Version 3.00, IBM Informix-ESQL Version 3.00.FC3DE
Software Serial Number AAA#B000000

If i open a phpinfo() website, it tells me under Environment that DBATE is DMY4.
 [2008-04-04 06:25 UTC] matthias dot djihangiroff at persona dot de
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);
 [2008-04-04 06:31 UTC] opendev at us dot ibm dot com
Can you try and install CSDK-2.9 locally on some other location, connect to Informix server using your DSN and check if it fails too? CSDK 2.9 passes for me.
 [2008-04-04 07:11 UTC] matthias dot djihangiroff at persona dot de
Sure, ill give you a feedback in a few days.
 [2008-04-04 07:39 UTC] matthias dot djihangiroff at persona dot de
Ok,

i installed CSDK 2.9
# esql -V
IBM Informix CSDK Version 2.90, IBM Informix-ESQL Version 2.90.FC4R1
Software Serial Number AAA#B000000

All is running fine now. No server crashes, and i can use german date formats.
 [2008-04-29 04:36 UTC] opendev at us dot ibm dot com
Hi 

Please close this bug.

Thanks
 [2008-04-29 04:45 UTC] matthias dot djihangiroff at persona dot de
Fixed
 [2010-12-07 04:15 UTC] matthias dot djihangiroff at persona dot de
This problem still exists with CSDK 3.70FC1

"esql -V
IBM Informix CSDK Version 3.70, IBM Informix-ESQL Version 3.70.FC1"

So we are unable to select from fields like bigint since the csdk2.9 doesn't support this field types.
 [2010-12-14 06:06 UTC] abhargav at in dot ibm dot com
Thank you for taking the time to write to us, but this is not
a bug.

Hi,

There were few issue with DBDATE and hence after v2.9 of CSDK, this feature has been rolled back.

Regards,
Ambrish Bhargava
 [2010-12-15 02:50 UTC] matthias dot djihangiroff at persona dot de
We want to upgrade to IDS 11.7FC1.
So how we deal with this defect? Stay with CSDK 2.9?
But than, we cant use IDS 11.7FC1
 [2010-12-15 04:11 UTC] abhargav at in dot ibm dot com
Hi,

As this is the problem with CSDK (and we can not do anything in PDO_INFORMIX extension), I suggest you talk to the CSDK/IDS team about this. May be open a PMR against IDS.

Regards,
Ambrish Bhargava
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 01:01:30 2024 UTC