[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    Re: mysql: DBI syntax question
From:       Random Junk <jsd () gamespot ! com>
Date:       1998-03-31 18:08:51
[Download RAW message or body]

Matt Ranney wrote this:
> IMHO using sprintf makes the string easier to understand, as in:
> 
> $st = sprintf "INSERT INTO YourTable VALUES (%s,%s,%d)",
> 	$dbh->quote($Q::make), $dbh->quote($Q::model), $Q::year;

imho, using prepare/execute makes it even easier to understand, and
very reusable.

    my $insert = $dbh->prepare("insert into yourtable values (?,?,?)");
       $insert->execute($Q::make, $Q::model, $Q::year)
                or warn "insert failed: " . $dbh->errstr;

no messing with $dbh->quote() all the time.  plus it makes doing stuff 
in a loop totally simple.


-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Plan: Eat right, exercise regularly, die anyway.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic