Link to home
Start Free TrialLog in
Avatar of Lynn Thames
Lynn ThamesFlag for United States of America

asked on

Could the php mssql_query function be locking tables in the SQL database?

Hi,  I am using the following code to query a remote SQL server with a select statement.  Could this be locking that database?

Thanks for any direction you can give!

$link = @mssql_connect($myServer,$myUser,$myPass);
mssql_select_db($myDB) or die('Couldn\'t load database');
$qry = "Select cast(GUIDProduct as varchar(36)) as myProductGUID, DATALENGTH(ProductPicture) as myImageSize, *
		from Product";
$rs = mssql_query($qry);
$RowCount = mssql_num_rows($rs);
if($RowCount>0){
	while($rows = mssql_fetch_assoc($rs)){
		//do something with recordset
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lynn Thames

ASKER

Thank you for your quick response.  

This definitely explains what's going on.  They are trying to import products into the database (which in that app requires exclusive lock during the import)  and at the same time my php script is syncing the products to their webstore . . . . . and their internet connection is so slow that a query that normally takes 1-2 seconds is taking 3 minutes!!!!!!!!!!
& Thanks for the quick grading :)

You will need to discuss this with the client then. If "syncing" I'd assume you only want valid data on the website, so using "with nolock" might be risky given that:
> an import might fail
> you are also being slowed down by connection speed.

They may be willing to use READ_COMMITTED_SNAPSHOT on perhaps?

Good luck with this project.

Paul