DShaneNYC
Joined: 02 Nov 2007 Posts: 1
|
Posted: Fri Nov 02, 2007 12:55 am Post subject: MDB2 and datatype arrays |
|
|
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! |
|