[Phplib-commit] CVS: php-lib-stable/php db_mysql.inc,1.8,1.9
Brought to you by:
nhruby,
richardarcher
From: Layne W. <lay...@us...> - 2002-03-14 20:36:48
|
Update of /cvsroot/phplib/php-lib-stable/php In directory usw-pr-cvs1:/tmp/cvs-serv13054/php Modified Files: db_mysql.inc Log Message: Modified lock() to allow list of table names. Modified lock() and unlock() to remove unnecessary variable for testing query. Added instance variable 'PConnect' to toggle between persistent and non-persistent database connections. Updated documentation to reflect above changes. Index: db_mysql.inc =================================================================== RCS file: /cvsroot/phplib/php-lib-stable/php/db_mysql.inc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** db_mysql.inc 12 Oct 2001 16:16:16 -0000 1.8 --- db_mysql.inc 14 Mar 2002 20:36:43 -0000 1.9 *************** *** 22,25 **** --- 22,26 ---- var $Debug = 0; ## Set to 1 for debugging messages. var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) + var $PConnect = 0; ## Set to 1 to use persistent database connections var $Seq_Table = "db_sequence"; *************** *** 41,45 **** - /* public: constructor */ function DB_Sql($query = "") { --- 42,45 ---- *************** *** 71,77 **** if ( 0 == $this->Link_ID ) { ! $this->Link_ID=mysql_pconnect($Host, $User, $Password); if (!$this->Link_ID) { ! $this->halt("pconnect($Host, $User, \$Password) failed."); return 0; } --- 71,81 ---- if ( 0 == $this->Link_ID ) { ! if(!$this->PConnect) { ! $this->Link_ID = mysql_connect($Host, $User, $Password); ! } else { ! $this->Link_ID = mysql_pconnect($Host, $User, $Password); ! } if (!$this->Link_ID) { ! $this->halt("connect($Host, $User, \$Password) failed."); return 0; } *************** *** 168,198 **** function lock($table, $mode = "write") { $query = "lock tables "; ! if (is_array($table)) { ! while (list($key,$value) = each($table)) { ! if (!is_int($key)) { ! // texts key are "read", "read local", "write", "low priority write" ! $query .= "$value $key, "; } else { ! $query .= "$value $mode, "; } } ! $query = substr($query,0,-2); } else { $query .= "$table $mode"; } ! $res = $this->query($query); ! if (!$res) { $this->halt("lock() failed."); ! return 0; } ! return $res; } function unlock() { ! $res = $this->query("unlock tables"); ! if (!$res) { $this->halt("unlock() failed."); } ! return $res; } --- 172,204 ---- function lock($table, $mode = "write") { $query = "lock tables "; ! if(is_array($table)) { ! while(list($key,$value) = each($table)) { ! // text keys are "read", "read local", "write", "low priority write" ! if(is_int($key)) $key = $mode; ! if(strpos($value, ",")) { ! $query .= str_replace(",", " $key, ", $value) . " $key, "; } else { ! $query .= "$value $key, "; } } ! $query = substr($query, 0, -2); ! } elseif(strpos($table, ",")) { ! $query .= str_replace(",", " $mode, ", $table) . " $mode"; } else { $query .= "$table $mode"; } ! if(!$this->query($query)) { $this->halt("lock() failed."); ! return false; } ! return true; } function unlock() { ! if(!$this->query("unlock tables")) { $this->halt("unlock() failed."); + return false; } ! return true; } |