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

[newbie] How to do "batch insert"?

From: 李彦 Ian Li <liyan82(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: [newbie] How to do "batch insert"?
Date: 2007-06-08 08:44:10
Message-ID: 466916DA.2080903@gmail.com (view raw or flat)
Thread:
Lists: pgsql-php
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

Responses

pgsql-php by date

Next:From: Mihail MihailovDate: 2007-06-08 10:34:40
Subject: Re: [newbie] How to do "batch insert"?
Previous:From: ChrisDate: 2007-05-29 00:18:55
Subject: Re: Get Extension in Bytea Type

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