From: | Jeff <threshar(at)torgo(dot)978(dot)org> |
---|---|
To: | Peter Galbavy <peter(dot)galbavy(at)knowtion(dot)net> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: how do i insert an empty string ? |
Date: | 2002-10-15 14:14:01 |
Message-ID: | 20021015101157.X65014-100000@torgo |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, 15 Oct 2002, Peter Galbavy wrote:
> FAQ: A search yielded nothing explicit...
>
> I have an INSERT statement:
>
> INSERT INTO metadata (md5, origin, name, value)
> VALUES ('fd859f263bd0579935f2146a22d24f32', 'EXIF',
> 'UserComment', '')
>
> but this fails (using Perl DBI, DBD::Pg) because $dbh->quote() returns two
Since you are using DBI, why not bind the variables and be done with it?
this would become
$query = $db->prepare("INSERT INTO metadata (md5, origin, name, value)
VALUES (?, ?, ?, ?)");
$query->execute($md5, $origin, $name, $value);
This way you don't have to deal with double quoting and all that. (You can
also call bind_param, but I find it easier to just pass args into execute)
------------------------------------------------------------------------------
Jeff Trout <jeff(at)jefftrout(dot)com> http://www.jefftrout.com/
Ronald McDonald, with the help of cheese soup,
controls America from a secret volkswagon hidden in the past
-------------------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-10-15 14:25:39 | Re: set difference |
Previous Message | Tom Lane | 2002-10-15 14:07:14 | Re: SQL function triggers |