Approach to data wrapping
- by Mikhail
I'm developing in PHP and MySQL.
The information about the currently logged in user is stored in many different tables. The information that I need on each page, I preload. However if something is needed from a rarely accessed table - then I do
$newdata = $db->Query('SELECT * FROM rare_table WHERE user_id='.$user->id);
I would like to simplify the above to a point where I don't have to specify that the query should be limited to this particular user. An ideal function call would be:
$newdata = $user->Query('SELECT * FROM rare_table');
Obviously I'd have to parse the SQL and add a WHERE clause. Or add to the already existing clause.
Questions: are there tools to do this? How can I develop this? Is this even a good idea?