If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > PDO and user defined types

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-10-11, 16:29
oshman oshman is offline
Registered User
 
Join Date: Oct 2011
Posts: 11
PDO and user defined types

I am going off this tutorial on UDT in DB2.

DB2 Basics: An introduction to structured data types and typed tables

I have a situation where I would like to be able to insert through PDO. So far, I've been unsuccessful.

I have tried like this where I specify each type value with a place holder:

------------------------------
$f_name = 'Tom';
$l_name = 'Jones';
$street = "111 Way St";
$city = 'Houston';
$state = 'TX';
$zip = '77007';
$type = "address_t() ..street($street) ..city($city) ..province($state) ..postal_code($zip)";

$stmt = $db->prepare("insert into clients (client_lname, client_fname, address) values (:db_insert_placeholder_1,:db_insert_placeholder_2 ,address_t() ..street(:db_insert_placeholder_3) ..city(:db_insert_placeholder_4) ..province(db_insert_placeholder_5) ..postal_code(db_insert_placeholder_6))");
$stmt->bindParam(':db_insert_placeholder_1',$f_name);
$stmt->bindParam(':db_insert_placeholder_2',$l_name);
$stmt->bindParam(':db_insert_placeholder_3',$street);
$stmt->bindParam(':db_insert_placeholder_4',$city);
$stmt->bindParam(':db_insert_placeholder_5',$state);
$stmt->bindParam(':db_insert_placeholder_6',$zip);
$stmt->execute();
------------------------------

And also like this, where I compile a string for the insert value:
------------------------------
$f_name = 'Tom';
$l_name = 'Jones';
$street = "111 Way St";
$city = 'Houston';
$state = 'TX';
$zip = '77007';
$type = "address_t() ..street($street) ..city($city) ..province($state) ..postal_code($zip)";

$stmt = $db->prepare("insert into clients (client_lname, client_fname, address) values (:db_insert_placeholder_1,:db_insert_placeholder_2 ,:db_insert_placeholder_3)");
$stmt->bindParam(':db_insert_placeholder_1',$f_name);
$stmt->bindParam(':db_insert_placeholder_2',$l_name);
$stmt->bindParam(':db_insert_placeholder_3',$type);
$stmt->execute();
------------------------------

I get "SQLSTATE[07001]: <<Unknown error>>: -99999 [IBM][CLI Driver] CLI0100E Wrong number of parameters." - So I guess my first question is whether this is even possible

Any help is appreciated
Reply With Quote
Reply

Tags
db2 pdo udt

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On