sql server php
Posted on 2012-09-16
i have a table name sms_in in a database . where he is contains the following attribute.
sms_inid(pk) \ sms_in_mobilenumber \ status \ sms_in_content \ sms_in_readflag \ sms_in_timestamp
the php script fetch " X" row from this table for proccessing
condition of query :
status = null / sms_in_readflag = 0
is the general query
when i read i update the fetched row to sms_in_readflag = 1 bcz this create will be in cron job to prevent reading this row two time !!
and update the sms_in_timestamp to the current time = last row modification
and sms_in_status = proccessing
a simple querry to move some sms to another table !
after finish sms_in_status = done
readflag = 0
this script should be repeated each time because allways we have new insertion in this table.. so my problem with ... the redundancy and acccess to row same time :S
and it may occurs copying of sms two time :S
i have read some topics about this solution
$stmt1 = sqlsrv_query( $conn, $tsql2, $params2 );
$stmt2 = sqlsrv_query( $conn, $tsql2, $params2 );
if( $stmt1 && $stmt2 )
sqlsrv_commit( $conn );
echo "Transaction was committed.<br/>";
$row = sqlsrv_fetch_array($stmt3);
sqlsrv_rollback( $conn );
echo "Transaction was rolled back.<br/>";
but i want when i select a row for example prevent to cron job to select a row i work on it ?? i have read some topics about isolation level 0 1 2 and SERIALIZABLE but i don't understand what is the difference between us
so what is the solution ??