Approach to data wrapping

Posted by Mikhail on Stack Overflow See other posts from Stack Overflow or by Mikhail
Published on 2011-01-06T22:32:16Z Indexed on 2011/01/06 22:54 UTC
Read the original article Hit count: 204

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql