...

View Full Version : Resolved locking a row



durangod
02-19-2013, 11:36 PM
im considering locking one row to a table so that the table will always have a default value.

im sure i can lock the table itself, and i know i can just use php to find the value and reject any delete query, but can i lock a single row id so that it cannot be removed just in the table config itself?

Old Pedant
02-20-2013, 01:36 AM
Short answer: No.

There are ways to accomplish row locking, but they only last so long as the connection to the DB is maintained. So you couldn't maintain a connection very well from PHP. You'd have to do it from, say, a command line window where you never closed the window.

A better way to do this is probably to use a VIEW or STORED PROCEDURE. (Besides, DB purists will urge you to do *ALL* web-based work on the DB via one of those and *NEVER* make ad hoc SQL queries!)

Your VIEW or PROC simply provides a default record if no record is found.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum