cvs: pearweb /include pear-database.php
| From: | Martin Jansen | Date: | Sun, 27 Jan 2002 09:47:55 +0000 |
| Subject: | cvs: pearweb /include pear-database.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2163@lists.php.net to get a copy of this message | ||
mj Sun Jan 27 04:47:55 2002 EDT
Modified files:
/pearweb/include pear-database.php
Log:
* Using prepare/execute is much nicer here.
Index: pearweb/include/pear-database.php
diff -u pearweb/include/pear-database.php:1.42 pearweb/include/pear-database.php:1.43
--- pearweb/include/pear-database.php:1.42 Sun Jan 27 04:42:26 2002
+++ pearweb/include/pear-database.php Sun Jan 27 04:47:55 2002
@@ -564,19 +564,20 @@
$id = $dbh->nextId("downloads");
- $query = sprintf("INSERT INTO downloads (id, file, package, release, dl_when, dl_who,
dl_host) VALUES ('%s', '%s', '%s', '%s', '%s',
'%s', '%s')",
- $id,
- $file,
- $package,
- $release_id,
- date("Y-m-d H:i:s"),
- $_SERVER['REMOTE_ADDR'],
- gethostbyaddr($_SERVER['REMOTE_ADDR'])
- );
-
- $sth = $dbh->query($query);
+ $query = "INSERT INTO downloads VALUES (?, ?, ?, ?, ?, ?, ?)";
+ $sth = $dbh->prepare($query);
if (DB::isError($sth)) {
+ return false;
+ }
+
+ $err = $dbh->execute($sth, array($id, $file, $package,
+ $release_id, date("Y-m-d H:i:s"),
+ $_SERVER['REMOTE_ADDR'],
+ gethostbyaddr($_SERVER['REMOTE_ADDR'])
+ ));
+
+ if (DB::isError($err)) {
return false;
} else {
return true;