Forum Moderators: coopster

Message Too Old, No Replies

Blocking the addition of rows in a table

is it possible

         

le_gber

9:24 am on Jun 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know that two of my tables will have a limited number of rows and want to block / limit the addition of new rows once the limit has been reached?

Is it possible?

dreamcatcher

9:38 am on Jun 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi le_gber,

One possible solution would be set up a count and increment the count each time a row is posted. So, check against that count each time a new row is added by comparing the count to the number of rows already in the system.

If it reaches the limit you want to impose, display an error message.

Or simply return the number of rows already in the system and check against that.

dc

le_gber

11:46 am on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there,

I was more thinking of blocking it on the mysqlserver level. Would this be done by setting user privileges?

jatar_k

5:49 pm on Jun 17, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



dc's way would work and be very reliable

you couldn't limit it in user priviledges because you can either allow them to insert or not, I don't believe you can set a limit on it

you could work with some table settings maybe, set an auto increment that only goes to a certain level, though I don't really think that will be very efficient.

If you really want to do it at that level, though I am not sure how, you should spend a bunch of time reading up on tables at mysql.com