I’m going to write PHP script, that uses table prefix for MySQL tables. Should I write all of requests like for example
$db_query='select * from '.$tbl_prefix.'sometable;';
or it’s possible to set some variable, that will add this prefix to all queries?
For example, I’m performing request
$db_query='select * from sometable;';
and MAGIC adds prefix to table itself, so for MySQL query will look like
select * from pref_sometable;
There’s no MySQL command to do that, you must implement it in your code just like you do at first. So:
Is fine.
If you don’t want to add a prefix on each query, you can create an object like this:
That’s not 100% PHP, it’s just and idea so you can get it.