Skip site navigation (1) Skip section navigation (2)

Re: [Q] PDO use to bind arrays for insert

From: Chris <dmagick(at)gmail(dot)com>
To: V S P <toreason(at)fastmail(dot)fm>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: [Q] PDO use to bind arrays for insert
Date: 2008-11-16 21:41:57
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php
V S P wrote:
> 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.

PDO doesn't let you send multiple queries in the one request.

Since you're connecting to postgres, you can use this to do a bulk-insert:

Though it's not part of pdo, and also postgres 'copy from stdin' is all 
or nothing - so if you have one line of bad data in there, none of it's 

Postgresql & php tutorials

In response to


pgsql-php by date

Next:From: V S PDate: 2008-11-17 03:01:13
Subject: Re: [Q] PDO use to bind arrays for insert
Previous:From: V S PDate: 2008-11-16 02:45:30
Subject: [Q] PDO use to bind arrays for insert

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group