I read a lot about locking databases, tables and rows but i want lower lock, like lock only 'operation' i don't know how to call it, lets say i have function in php:
function update_table()
{
//querys like SELECT, UPDATE INSERT etc.
}
Now, i want to only one person can use this function at the same time, and other will need to wait until the first one finish
But it is possible to lock not table/row but only this function, so others queries with SELECT etc. can be executed with no problem? or maybe better is just lock the table? (problem is that this table is very important and i don't want to lock it because some other users can visit the site for other resons/other pages and if many people will wait in line for this code above, other visitors also will have to wait even that they have no interests in site with code above)
Yes. You can use GET_LOCK and RELEASE_LOCK mysql functions