php - Deadlock when updating table in MSSQL -


i need delete external links "content" column.

<?php  require_once('phpquery-onefile.php');  $connectioninfo = array( "database"=>"database", "uid"=>"user", "pwd"=>"pass"); $conn = sqlsrv_connect( 'server', $connectioninfo);  if( $conn ) {  }else{      echo "connection not established.<br />";      die( print_r( sqlsrv_errors(), true)); }  $query = "select articleid, content articles content '%href%';"; $stmt=sqlsrv_query($conn,$query);  if (!$stmt) {     die(print_r(sqlsrv_errors(), true)); }   while( $row = sqlsrv_fetch_array( $stmt, sqlsrv_fetch_assoc) ) {         $cont_old = $row['content'];     $ch = false;     $dom = phpquery::newdocumenthtml($cont_old, 'cp1251');     foreach ($dom->find('a') $a) {         $a = pq($a);         if (strpos($a->attr('href'), '/biblio/') === false) {             $ch = true;             print "link = " . iconv('cp1251', 'cp866//ignore', $a->attr('href') . " -> " . $a->html()) ."\n";             $a = pq($a);             $a->replacewith($a->html());         }     }     $cont = $dom->htmlouter();       if ($ch) {         $sql2 = 'update articles set content = ? articleid = ?';         $stmt2 = sqlsrv_prepare($conn, $sql2, array(&$cont, &$row['articleid']));         if( sqlsrv_execute( $stmt2 ) === false ) {             print "id={$row['articleid']} error: ";             print_r( sqlsrv_errors());             print "\n";         } else {             print "updated id={$row['articleid']}\n";         }      } }  sqlsrv_close($conn);  print "end\n"; 

this throws error:

[microsoft][sql server native client 10.0][sql server]transaction (process id 60) deadlocked on lock | communication buffer | generic waitable object resources process , has been chosen deadlock victim. rerun transaction.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -