sql server  php

Posted on 2012-09-16
Last Modified: 2012-10-02
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 ??
Question by:afifosh
    1 Comment
    LVL 82

    Accepted Solution

    I'm really not sure what you're trying to do except that running the query twice isn't going to get you anything useful.  It does not return data:   In addition, that's not the way to use it with 'sqlsrv_commit()'.  For that, look at Example #1 on this page:

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Via a live example, show how to shrink a transaction log file down to a reasonable size.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now