Wednesday, 7 August 2013

Globally disable all MySQL writes

Globally disable all MySQL writes

I am using PHP's PDO with MySQL to create a web application. I wish to put
the web application in "demo" mode. What this means is all writes
(updates, inserts, deletes) are disabled, and the applicable continues
with out any errors. For arguments sake, the application is in demo mode
if $_SESSION['demo_mode']=1. Without putting conditionals around each
write statement, how can this be done.
$dbh->exec("INSERT INTO t1(c1, c2) VALUES ('v1', 'v2')");
$dbh->lastInsertId();
$q=$dbh->query("SELECT c1 FROM t2 WHERE c2=123");
$v=$q->fetchColumn();

No comments:

Post a Comment