[Phplib-commit] CVS: php-lib/php/db/mysql db_sql.inc,1.11,1.12
Brought to you by:
nhruby,
richardarcher
From: Layne W. <lay...@us...> - 2001-10-12 16:19:44
|
Update of /cvsroot/phplib/php-lib/php/db/mysql In directory usw-pr-cvs1:/tmp/cvs-serv28837/php/db/mysql Modified Files: db_sql.inc Log Message: 1. use $this->query() in both lock() and unlock() 2. removed redundant check of the $table array key 3. remove lock()'s locking mode limit of "read" and "write" when multiple tables are locked "read local" and "low priority write" are both valid MySQL locks, but are not accepted by the previous function Index: db_sql.inc =================================================================== RCS file: /cvsroot/phplib/php-lib/php/db/mysql/db_sql.inc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** db_sql.inc 2001/09/03 10:12:25 1.11 --- db_sql.inc 2001/10/12 16:19:29 1.12 *************** *** 164,187 **** /* public: table locking */ ! function lock($table, $mode="write") { ! if (!$this->connect()) { ! return 0; /* we already complained in connect() about that. */ ! } ! ! $query="lock tables "; if (is_array($table)) { ! while (list($key,$value)=each($table)) { ! if ($key=="read" && $key!=0) { ! $query.="$value read, "; } else { ! $query.="$value $mode, "; } } ! $query=substr($query,0,-2); } else { ! $query.="$table $mode"; } ! $res = @mysql_query($query, $this->Link_ID); ! if (!$res) { $this->halt("lock() failed."); return 0; --- 164,184 ---- /* public: table locking */ ! 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; *************** *** 191,199 **** function unlock() { ! if (!$this->connect()) { ! return 0; /* we already complained in connect() about that. */ ! } ! ! $res = @mysql_query("unlock tables", $this->Link_ID); if (!$res) { $this->halt("unlock() failed."); --- 188,192 ---- function unlock() { ! $res = $this->query("unlock tables"); if (!$res) { $this->halt("unlock() failed."); |