PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
MDB2 and datatype arrays

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database
View previous topic :: View next topic  
Author Message
DShaneNYC



Joined: 02 Nov 2007
Posts: 1

PostPosted: Fri Nov 02, 2007 12:55 am    Post subject: MDB2 and datatype arrays Reply with quote

I have a PostGreSQL database with several tables that have columns with arrays of type real. I am using MDB2.

When inserting data into these tables, I don't know how to quote the array data, whether it is in a PHP array or simply a text string '{1,2,3,4,5}'

The latter worked just fine in PEAR :: DB, but not in MDB2.

I tried using the real and text data types, but they don't work. I get native errors that say my date needs to be type casted.

Short of defining my own MDB2 data type, is there a way of inserting array data into a single array column in a table of my PostGreSQL database? The ARRAY construction is standard SQL, so it should be part of MDB2.

Here is an example:

$id = 'AAA';
$data = '{1,2,3,4,5}';

$db->exec('INSERT INTO mytable (id, data) VALUES (' .
$db->quote($id, 'text') . ', ' .
$db->quote($data, '????????') . ')');

and the table is:
CREATE TABLE mytable (
id varchar(10),
data real[]
);

What should the ???????? be?

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software