|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-08-28 16:01 UTC] Brian_Teravskis at Cargill dot com
I'm using FreeTDS 0.51 to access an MSSQL 7.0 pl1 database server. I can use PHP to SELECT information from the database with no problems. I'm having problems with multiple insert/updates done to the database in sequence. My algorithm attempts to insert/update several rows of data into the database after an HTTP put. It will first attempt to do an SQL insert, and if that errors due to duplicate key restraints it will do an SQL update. I'm finding that it will do the first update, but after that nothing appears to work unless I close the connection to the database and reopen it again. While this works in a small installation, I can see problems with hundreds of database updates per minute constantly opening and closing connections for each row updated. I can do multiple SQL inserts in sequence with no problems. It is when the key restraint warning occurs and I do an update. I have the code if interested. Here is my PHP configure line: ./configure --with-mysql --with apxs=/usr/local/apache/bin/apxs --with-gd --with-mssql=/usr/local/freetds --with-sybase=/usr/local/freetds --enable-track-vars Thanks PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
//im coding this code to update multiple records but how come it will only update one record wherein it is the first record...please help...thanks $temphandle=explode(",",$_POST["oldname"]); $tempcount=count($temphandle); //load old names and project handled and delete entries for($a=0; $a < $tempcount; $a++) { $link=mysql_connect("$host","$user","$password"); mysql_select_db($dbname,$link); $test="select * from employlist where employlist.fname='".$temphandle[$a]."'"; $display=mysql_query($test,$link); $row=mysql_num_rows($display); if($row<>0){ $row=mysql_fetch_array($display); $htemp=explode(",",$row["projects"]); $hcnttemp=count($htemp); $tempvalue=""; $del=0; for($cnt=0;$cnt < $hcnttemp; $cnt++){ if($htemp[$cnt]!=$projname){ if((abs($hcnttemp-$cnt-$del))<=2){ $tempvalue.=$htemp[$cnt]; }else{ $tempvalue.=$htemp[$cnt].","; } }else{ $del++; } } $Query = "Update employlist set employlist.projects='". $tempvalue."' where employlist.fname='".$temphandle[$a]."'"; $save=mysql_query($Query); if(!$save) print "did not save"; } $display = null; $test=null; $row=null; mysql_close($link); }