?
Solved

sql server  php

Posted on 2012-09-16
1
Medium Priority
?
516 Views
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);
}
else
{
    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 ??
0
Comment
Question by:afifosh
1 Comment
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 300 total points
ID: 38403663
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:  http://us2.php.net/manual/en/function.sqlsrv-query.php   In addition, that's not the way to use it with 'sqlsrv_commit()'.  For that, look at Example #1 on this page: http://us2.php.net/manual/en/function.sqlsrv-commit.php
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

839 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