[PHP-DB] Re: [PHP-WIN] Select the specific user data from the database

2010-09-06 Thread Richard Quadling
On 5 September 2010 12:21, nagendra prasad nagendra802...@gmail.com wrote:
 Hi Experts,

 I have a mysql database. What I want is that when a user login he can able
 to see his entries only, so that he can delete, add or edit his entries
 only. I have 2 different tables one for user details and another for actual
 entries. Please help me.

 Best,
 Guru.


If userA's and userB' data are both in the same table, do or will you
have issues with key fields?

I don't know what the data is, but you would need to include some
element of the user in every unique constraint.

Depending upon the data, another option is to have a separate table or
database per user. This allows for user permissions to be assigned to
the table or database.

I've used this mechanism when users data needs to be sync across
multiple devices and the device initiating the sync was always the
most uptodate. Cloning a table was far easier.

Richard.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: [PHP-WIN] Select the specific user data from the database

2010-09-06 Thread Paul Vatta
You could also try the following approach:
- on the table, have an INSERT trigger add the username to a column
named CREATE_WHO (this can be extended to UPDATE operations too, but
this probably isn't necessary in your example)
- create a view based on select * from table where CREATE_WHO =
SUBSTRING_INDEX(USER(),'@',1);.
- DML statements are now applied against the view, and not against the
underlying table.
This depends on the user who is logged in to the DB though.

Hope this helps,
Paul

On 6 September 2010 19:38, Richard Quadling rquadl...@gmail.com wrote:

 On 5 September 2010 12:21, nagendra prasad nagendra802...@gmail.com wrote:
  Hi Experts,
 
  I have a mysql database. What I want is that when a user login he can able
  to see his entries only, so that he can delete, add or edit his entries
  only. I have 2 different tables one for user details and another for actual
  entries. Please help me.
 
  Best,
  Guru.
 

 If userA's and userB' data are both in the same table, do or will you
 have issues with key fields?

 I don't know what the data is, but you would need to include some
 element of the user in every unique constraint.

 Depending upon the data, another option is to have a separate table or
 database per user. This allows for user permissions to be assigned to
 the table or database.

 I've used this mechanism when users data needs to be sync across
 multiple devices and the device initiating the sync was always the
 most uptodate. Cloning a table was far easier.

 Richard.


 --
 Richard Quadling
 Twitter : EE : Zend
 @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

 --
 PHP Windows Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php