Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0AFDF64FD63 for ; Sun, 16 Nov 2008 17:42:09 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 20955-05 for ; Sun, 16 Nov 2008 17:42:06 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.232]) by mail.postgresql.org (Postfix) with ESMTP id 24B5164FCE3 for ; Sun, 16 Nov 2008 17:42:05 -0400 (AST) Received: by rv-out-0506.google.com with SMTP id b25so2061320rvf.43 for ; Sun, 16 Nov 2008 13:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=mn5eiwgZuoIXkmp0NwaPHcO0wHhzRj04oNhEe8+OCZY=; b=BnGrfiPJi7bx1UXPYaSg4RD9xrtWEhsvI1dmOAaGCua5pi9htNhlu9/WA/DyfzXqXh F4JuRwAoyVJXbfEvjqxLTJUYlZqdaJ8HV4frVGLYa+4/1VB9z8ToVS6WKTmctwzuE7qU LhrQKj6oO/TmwEvuLTmGGg6vkuS2022sNEn2M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=maK1Z8onK2IY22nlYv0tq9qvFXu1GPF5IvNaj6nNQwqREqlOvRMYkmexij+tmIQ1+a pOAazFDRxGXiRKcIGBoYMN0EMx7ONVt4KSjoDaTIdik3FC6jeSuq1hhGaFoJTu91UEdL AXw49dwAA03GCKO4uy+iUqoJOv6+stDRt+pag= Received: by 10.141.53.20 with SMTP id f20mr1848130rvk.192.1226871724707; Sun, 16 Nov 2008 13:42:04 -0800 (PST) Received: from ?192.168.0.70? (office.squiz.net [203.206.128.174]) by mx.google.com with ESMTPS id f42sm5155185rvb.6.2008.11.16.13.42.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 16 Nov 2008 13:42:03 -0800 (PST) Message-ID: <492093A5.7040606@gmail.com> Date: Mon, 17 Nov 2008 08:41:57 +1100 From: Chris User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: V S P CC: pgsql-php@postgresql.org Subject: Re: [Q] PDO use to bind arrays for insert References: <1226803530.24888.1284994985@webmail.messagingengine.com> In-Reply-To: <1226803530.24888.1284994985@webmail.messagingengine.com> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/12 X-Sequence-Number: 3923 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: http://www.php.net/manual/en/function.pg-put-line.php 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 committed. -- Postgresql & php tutorials http://www.designmagick.com/