php - Globally disable all MySQL writes -
i using php's pdo mysql create web application. wish put web application in "demo" mode. means writes (updates, inserts, deletes) disabled, , applicable continues out errors. arguments sake, application in demo mode if $_session['demo_mode']=1. without putting conditionals around each write statement, how can done.
$dbh->exec("insert t1(c1, c2) values ('v1', 'v2')"); $dbh->lastinsertid(); $q=$dbh->query("select c1 t2 c2=123"); $v=$q->fetchcolumn();
you can modify rights of user application connects as, gets select
and similar rights.
here comprehensive list of individual rights can grant user.
example (to adapted need, of course):
revoke privileges on yourdatabase.* 'application_user'@'host'; grant select on yourdatabase.* 'application_user'@'host';
obviously, produce errors when application tries write anything. app should prepared fail graciously if planning use demo ;)
Comments
Post a Comment