php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58575 Inserting LOB in Informix Database
Submitted: 2009-03-04 03:08 UTC Modified: 2009-03-06 05:48 UTC
From: marco dot we at gmx dot de Assigned:
Status: Open Package: PDO_INFORMIX (PECL)
PHP Version: 5.2.5 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marco dot we at gmx dot de
New email:
PHP Version: OS:

 

 [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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-04 04:00 UTC] abhargav at in dot ibm dot com
Hi,

Thanks for reporting this. 

I think the examples that we are shipping with the source code of PDO_INFORMIX might be helpful to you (to be accurate look into tests/fvt_015.phpt). You can download source from: http://pecl.php.net/package/pdo_informix

I hope this will solve your problem.

Regards,
Ambrish Bhargava
 [2009-03-04 04:31 UTC] marco dot we at gmx dot de
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?
 [2009-03-04 05:19 UTC] marco dot we at gmx dot de
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)'
 [2009-03-04 05:51 UTC] abhargav at in dot ibm dot com
Hi,

Now, this is problem with PDO_INFORMIX extension. I am looking into the issue. Will get back to you with fix.

Regards,
Ambrish Bhargava
 [2009-03-05 02:22 UTC] abhargav at in dot ibm dot com
Hi,

Can you provide me the version of IDS and CSDK that you are using?

Regards,
Ambrish Bhargava
 [2009-03-05 05:28 UTC] marco dot we at gmx dot de
Hello,

the version are:

IDS: 7.31.UC2
CSDK: 2.81.UC2
 [2009-03-05 05:37 UTC] abhargav at in dot ibm dot com
Hi,

Please upgrade your CSDK version to 2.90 or higher as PDO_INFORMIX is supported form this version onwards. With older versions (like in your case it is 2.81) it may work but not necessarly in expected manner.

Regards,
Ambrish Bhargava
 [2009-03-05 08:26 UTC] marco dot we at gmx dot de
Ok,

now i've changed the hoel system to a Linux machine.
We have a 2.6.24 kernel and i'm using the lampp package in version 1.7.0 including the delveloper package.

We have updatet the CSDK to version 3.5.0.
The PDO driver i'm testing is Version 1.2.6

I'm followed this guide http://www.ibm.com/developerworks/blogs/page/idsteam?entry=openadmin_tool_xampp_installation_on

Now, it dosnt matter which PDO_INFORMIX package i'm trying, on a shell with php -f test.php im getting an 
inserting from php variable
Segmentation fault

when trying to test with this test.php:

<?php

class Test {
	
	public $db = null;
	public $dsn = null;
	public $user = null;
	public $pass = null;
	
	public function __construct( $_dsn = null , $_user = null , $_pass = null )
	{
		$this->user = "username";
		$this->pass = "passwd";
		$this->db = "db_name";
		
	}
	
	public function connect($autoCommit=true)
	{
		$this->db = new PDO("informix:host=hostname; service=1526; database=". $this->db ."; server=". $this->db ."; protocol=onsoctcp;EnableScrollableCursors=1", $this->user, $this->pass ); 
		
		$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		$this->db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER);
		$this->db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
		return $this->db;
	}
	
	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 ){}

		
		try {
		/* Create the test table */
		$server_info = $this->db->getAttribute(PDO::ATTR_SERVER_INFO);
		$create = 'CREATE TABLE animals (id INTEGER, my_clob text, my_blob byte)';
		$res = $this->db->exec( $create );

		$stmt = $this->db->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<br>";
		$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();

		$stmt = $this->db->prepare( 'select id,my_clob,my_blob from animals' );
		$res = $stmt->execute();
		$res = $stmt->fetchAll();
		var_dump( $res );

		
	}
	catch (Exception $e ) {
		print $e->getMessage();
	}

		print "done\n";
	}
}

	$testcase = new Test();
	$testcase->runTest();

?>
 [2009-03-05 13:08 UTC] abhargav at in dot ibm dot com
Thanks for your notification. I will get back to you.

Regards,
Ambrish Bhargava
 [2009-03-06 04:17 UTC] abhargav at in dot ibm dot com
Hi,

There is problem with TEXT field in PDO_INFORMIX. Please change TEXT to CLOB in the sample that you have provided.

Change:
>>>
$create = 'CREATE TABLE animals (id INTEGER, my_clob text, my_blob
byte)';
<<<

To:
>>>
$create = 'CREATE TABLE animals (id INTEGER, my_clob CLOB, my_blob
byte)';
<<<

Regards,
Ambrish Bhargava
 [2009-03-06 05:02 UTC] marco dot we at gmx dot de
Hello,

thank you for your efforts.
Now i get this mesage:

SQLSTATE[42000]: Syntax error or access violation: -201 [Informix][Informix ODBC Driver][Informix]A syntax error has occurred. (SQLExecDirect[-201] at /opt/lampp/lib/php/extensions/PDO_INFORMIX-1.2.6/informix_driver.c:268)

And this is only a test database. In the original one i cannot change the column datatype.
 [2009-03-06 05:29 UTC] abhargav at in dot ibm dot com
Hi,

What is the DDL for the table (CREATE TABLE statement) which is there on the server?

Regards,
Ambrish Bhargava
 [2009-03-06 05:36 UTC] marco dot we at gmx dot de
Hi,

you mean for the original table and not this test table?
This table exists in the meantime for five years. I have not the create statement.
 [2009-03-06 05:39 UTC] abhargav at in dot ibm dot com
Hi,

Test table is enough (meldung).

Regards,
Ambrish Bhargava
 [2009-03-06 05:48 UTC] marco dot we at gmx dot de
Hello,

oh now i'm testing with the table animals.
The table meldung from my first post was like the table animals.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 17:01:28 2024 UTC