tags:

views:

91

answers:

1

I'm using memcache to cache database objects, for example user rows.

when a user row does not exist, I would like to create an 'empty' database object, similar to the one mysql would return for a user query, fill it with data and use it. I don't want to create a new database row for the new user at this point. (it will be created at later time by background process).

How can I efficiently create an object with attributes similar to the user database object mysql would return without actually creating the user row and reading it?

A: 

The answer to this question, as has already been suggested, depends on what you're using to connect/query the mysql server. For example, the bulk of PHP code out there dealing with mysql databases uses mysql_query()/mysql_fetch_array() - which doesn't give any kind of "object". If you're using PDO or mysqli or mysql_fetch_object, the answer will differ depending on which one it is.

TML