pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 李彦 Ian Li <liyan82@gmail.com>
To: pgsql-php@postgresql.org
Subject: [newbie] How to do "batch insert"?
Date: Fri, 08 Jun 2007 16:44:10 +0800
Message-ID: <466916DA.2080903@gmail.com> (raw)

Hi all.
In the scene I want to insert all elements of an array in to a 
table, how can I do to commit them as a whole?
currently I do like this:

<?php
$result = pg_prepare($dbconn, "ins_acl", 'INSERT INTO 
acls(oid,uid,gid,mod) VALUES($1,$2,$3,$4)');
for($i=0;$i<count($p["acls"]);$i++){
	pg_execute($dbconn, "ins_lgs",$p["acls"][i]);
}
?>

I wonder while doing so, will it commit in each LOOP or just ONCE?

Thanks and Regards,

Ian



view thread (2+ messages)  latest in thread

Message-ID: <466916DA.2080903@gmail.com>
Permalink:  ../466916DA.2080903@gmail.com/
Also on:    postgresql.org/message-id/466916DA.2080903@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: liyan82@gmail.com
  Subject: Re: [newbie] How to do "batch insert"?
  In-Reply-To: <466916DA.2080903@gmail.com>
  References: <466916DA.2080903@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox