[Q] PDO use to bind arrays for insert

From: "V S P" <toreason(at)fastmail(dot)fm>
To: pgsql-php(at)postgresql(dot)org
Subject: [Q] PDO use to bind arrays for insert
Date: 2008-11-16 02:45:30
Message-ID: 1226803530.24888.1284994985@webmail.messagingengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi,
I appologize in advance, if this is not the right place
to ask (but I would appreciate then a pointer where I could ask)

I am using PHP 5.2.6 and Postgres 8.3 both on windows right now.

Wanted to know if there is a way to pass via PDO (because
that's how I connect now to Postgres)

an array of values to insert at once

for example:

I have a PHP class:

cwork
$work_id;
$work_desc;

I have, say, an array of 50 objects of type cwork

arr_work

I would like to insert all items in the array at once
so that I would do one trip to the database.

instead of performing insert SQL in a loop for each item.

In oracle such functionality is called array inserts or bulk
insert (sometimes). And in C++/OCI the interface is to basically
specifying a character array of values (with byte offsets)
for eacho of the fields.

So there would be an array of work_id, and array of work_desc
and both of those of the same length would have been specified
and bound to the bind variables

Thanks in advance,
VSP

--
V S P
toreason(at)fastmail(dot)fm

--
http://www.fastmail.fm - Or how I learned to stop worrying and
love email again

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Chris 2008-11-16 21:41:57 Re: [Q] PDO use to bind arrays for insert
Previous Message Andy Anderson 2008-11-12 13:16:34 Re: See postgre tables from PHP code