PEAR::DB (DB_mysql) - Locking/Unlocking Tables
| From: | Dennis Sterzenbach | Date: | Fri, 26 Sep 2003 14:41:48 +0000 |
| Subject: | PEAR::DB (DB_mysql) - Locking/Unlocking Tables | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8059@lists.php.net to get a copy of this message | ||
Hi again,
I try to write a simple PHP script allowing me to
administer users of my FTP (bases on MySQL auth, therefore
a table 'ftp_users' exists).
For any UPDATE/INSERT/DELETE I do steps like the following
code updating username (uname) for some userid (uid):
$db->autoCommit(false);
$db->simpleQuery("LOCK TABLES users WRITE;");
$sql = sprintf("UPDATE ftp_users SET uname='%s' WHERE uid=%d;", $name,
$uid);
$result = $db->simpleQuery($sql);
$db->simpleQuery("UNLOCK TABLES");
if (DB::isError($result)) {
$db->rollback();
// redirect to error-page
} else {
$db->commit();
}
Wouldn't it be nice, to add features like locking/unlocking
tables to DB_mysql?
Best Regards
Dennis Sterzenbach