Bug #60277 [Opn]: User Defined Types handling
| From: | ash at inode dot me | Date: | Sat, 19 Nov 2011 10:08:13 +0000 |
| Subject: | Bug #60277 [Opn]: User Defined Types handling | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165350@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60277&edit=1
ID: 60277
User updated by: ash at inode dot me
Reported by: ash at inode dot me
Summary: User Defined Types handling
Status: Open
Type: Bug
Package: PDO_IBM
Operating System: Linux
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
This was a false alarm. The queries don't work properly but it likely has nothing
to do with the driver. Look here for the solution:
http://www.dbforums.com/db2/1671711-udt.html#post6525422
Previous Comments:
------------------------------------------------------------------------
[2011-11-12 08:32:03] ash at inode dot me
Description:
------------
PHP - 5.3.2 latest Ubuntu package, PDO_IBM-1.3.2
Using a PDO object to insert even the simplest UDT produced error. This occurs
in cases when using PrepareStatements or calling query() directly. Using the
following tutorial as an example:
http://www.ibm.com/developerworks/data/library/techarticle/dm-0506melnyk/
Executing the following produces - SQLSTATE[07001]: <<Unknown error>>: -99999
[IBM][CLI Driver] CLI0100E Wrong number of parameters. SQLSTATE=07001
(SQLExecute[-99999] at /usr/share/php/PDO_IBM-1.3.2/ibm_statement.c:986)
$a = 'Some'; $b = 'Person'; $c = '21 Street'; $d = 'Some
City'; $e = 'MyState';
$f = '10101';
$stmt = $db->prepare("insert into clients (client_lname, client_fname) values
(:1, :2, address_t() ..street(:3) ..city(:4) ..province(:5)
..postal_code(:6))");
$stmt->bindParam(':1',$e);
$stmt->bindParam(':2',$f);
$stmt->bindParam(':3',$a);
$stmt->bindParam(':4',$b);
$stmt->bindParam(':5',$c);
$stmt->bindParam(':6',$d);
The following produces - SQLSTATE[42601]: Syntax error: -104 [IBM][CLI Driver]
[DB2/LINUX] SQL0104N
$db->query("insert into clients (client_lname, client_fname, address) values
('Some', 'Person', address_t() ..street($c) ..city($d) ..province($e)
..postal_code($f))");
This works - but if you want to insert LOBs you really have no options:
$db->query("insert into clients (client_lname, client_fname, address) values
('Some', 'Person', address_t() ..street('". $a ."')
..city('" .$b ."')
..province('". $c . "') ..postal_code('". $d ."'))");
Test script:
---------------
Create $db PDO connection and rung
try {
$a = 'Some'; $b = 'Person'; $c = '21 Street'; $d = 'Some
City'; $e = 'MyState'; $f = '10101';
/*
$stmt = $db->prepare("insert into clients (client_lname, client_fname) values (:1, :2,
address_t() ..street(:3) ..city(:4) ..province(:5) ..postal_code(:6))");
$stmt->bindParam(':1',$a);
$stmt->bindParam(':2',$b);
$stmt->bindParam(':3',$c);
$stmt->bindParam(':4',$d);
$stmt->bindParam(':5',$e);
$stmt->bindParam(':6',$f);
$stmt->execute();*/
$db->query("insert into clients (client_lname, client_fname, address) values
('Some', 'Person', address_t() ..street($c) ..city($d) ..province($e)
..postal_code($f))");
#$db->query("insert into clients (client_lname, client_fname, address) values
('Some', 'Person', address_t() ..street('". $a ."')
..city('" .$b ."') ..province('". $c . "')
..postal_code('". $d ."'))");
} catch (PDOException $e) {
print $e->getMessage() . "\n";
}
Expected result:
----------------
Named or unnamed placeholders should be bound properly and inserted.
Actual result:
--------------
See errors above
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60277&edit=1