Select only on record?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gertrudis
Forum Newbie
Posts: 14
Joined: Wed Jan 27, 2010 8:15 pm

Select only on record?

Post by gertrudis »

Hi to all.

I have a table with 13g record, and they're 20 user selecting record from that specific table.

Some time when they are selecting record, the same record appear in 2,3,4,5 user at the same time.
I neet something that when a record is select it for one user could not be select from other at the same time, but with giving lock record or any thing like that.

there is something in the select-sql that could prevent this to happens?
this is my sql-selete command:

$result = mysql_query("SELECT * FROM customer WHERE isnewclient='NL' and iduser='') ", $link);
immediately i update the record:
$phone_number=$row[1];
$result = mysql_query("UPDATE customer SET iduser='$username' WHERE phone_number='$phone_number'") or die(mysql_error());
but any way more than 1 people is getting duplicate
thanks in advance
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Select only on record?

Post by aravona »

Bit hard to understand you but if I'm understanding correctly:

You're wanting to select a record for 1 user only, but its bringing up records from other users as well ?
gertrudis
Forum Newbie
Posts: 14
Joined: Wed Jan 27, 2010 8:15 pm

Re: Select only on record?

Post by gertrudis »

I have 20 user in different computer, all of then accessing the same database.

Every things is OK, but once a while 2 or more user get the same record in they're screen, i need to avoid that one record from db appear in more than 1 user.

I have try select for update but when i try to update all user freeze.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Select only on record?

Post by mikosiko »

gertrudis wrote:I have 20 user in different computer, all of then accessing the same database.

Every things is OK, but once a while 2 or more user get the same record in they're screen, i need to avoid that one record from db appear in more than 1 user.

I have try select for update but when i try to update all user freeze.
You can find information about locking mechanism and strategies here for Innodb:
http://dev.mysql.com/doc/refman/5.0/en/ ... s-set.html

and here:
http://dev.mysql.com/doc/refman/5.0/en/ ... modes.html

your final goal (don't allow the user to see records being seeing or used for others users) is highly unusual in database concepts and implementation
gertrudis
Forum Newbie
Posts: 14
Joined: Wed Jan 27, 2010 8:15 pm

Re: Select only on record?

Post by gertrudis »

thanks a lot mikosiko
Change table engine to innodb works.
Post Reply