DBD::Mysql UPDATE/REPLACE quoti ng of parameters

DBD::Mysql UPDATE/REPLACE quoti ng of parameters

am 21.09.2006 16:10:02 von Eduard

Hi, I have an issue.

Working on an amd64 machine running debian-testing.

Mysql.pm: $VERSION = '1.2401';
DBD::Mysql.pm: $VERSION = '3.0006';

I have the following
simple code:

use strict;
use warnings;

use DBI;

my $dbh = DBI->connect("DBI:mysql:nvb2", 'root', undef);

$dbh->do(q{ UPDATE `dbfs` SET file='BLA', owner=3, type='text' WHERE
name = ? AND owner = ? }, {}, ('test', 5) );

$dbh->disconnect();


This work just fine, but when I replace the word UPDATE with REPLACE
it starts to quote the second parameter. The error is:

DBD::mysql::db do failed: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'WHERE name = 'test' AND owner = '5'' at line 1 at
t.pl line 7.


Am I missing something or is this a bug?

Thanks in advance,

Eduard


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: DBD::Mysql UPDATE/REPLACE quoti ng of parameters

am 21.09.2006 20:09:05 von Jim Winstead

On Thu, Sep 21, 2006 at 04:10:02PM +0200, eduard W. Lohmann wrote:
> Working on an amd64 machine running debian-testing.
>
> Mysql.pm: $VERSION = '1.2401';
> DBD::Mysql.pm: $VERSION = '3.0006';
>
> I have the following
> simple code:
>
> use strict;
> use warnings;
>
> use DBI;
>
> my $dbh = DBI->connect("DBI:mysql:nvb2", 'root', undef);
>
> $dbh->do(q{ UPDATE `dbfs` SET file='BLA', owner=3, type='text' WHERE
> name = ? AND owner = ? }, {}, ('test', 5) );
>
> $dbh->disconnect();
>
>
> This work just fine, but when I replace the word UPDATE with REPLACE
> it starts to quote the second parameter. The error is:
>
> DBD::mysql::db do failed: You have an error in your SQL syntax; check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near 'WHERE name = 'test' AND owner = '5'' at line 1 at
> t.pl line 7.
>
> Am I missing something or is this a bug?

No, the quoting of the second parameter is not a problem. The problem is
that the REPLACE statement does not support a WHERE clause.

See http://dev.mysql.com/doc/refman/5.0/en/replace.html

Jim

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org