[phpMP-CVS] CVS: phpMP/dba mysql.dba,1.13,1.14
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2002-07-25 06:16:26
|
Update of /cvsroot/phpmp/phpMP/dba In directory usw-pr-cvs1:/tmp/cvs-serv16001/dba Modified Files: mysql.dba Log Message: Fixed a few bugs; changed a template or two. Expect HUGE update of teomplate engine on next go-around. Index: mysql.dba =================================================================== RCS file: /cvsroot/phpmp/phpMP/dba/mysql.dba,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** mysql.dba 23 Apr 2002 08:14:54 -0000 1.13 --- mysql.dba 25 Jul 2002 06:16:22 -0000 1.14 *************** *** 1,3 **** ! <? /****************************************************************************** --- 1,3 ---- ! <?php /****************************************************************************** *************** *** 45,52 **** var $identLink; function connect() { global $MPCONF, $db; ! $db = @mysql_connect($MPCONF['DB']['host'], $MPCONF['DB']['username'], $MPCONF['DB']['password']); if (!$db) { $this->connected = 0; --- 45,55 ---- var $identLink; + var $stats; + var $connected; function connect() { global $MPCONF, $db; ! if (empty($this->identLink)) { ! $db = @mysql_connect($MPCONF['DB']['host'], $MPCONF['DB']['username'], $MPCONF['DB']['password']); if (!$db) { $this->connected = 0; *************** *** 54,61 **** --- 57,90 ---- } else { $this->identLink = $db; + $this->select_db($MPCONF['DB']['database']); return $db; } + } else { + return $this->identLink; + } + } + + function p_connect() { + global $MPCONF, $db; + if (empty($this->identLink)) { + $db = @mysql_connect($MPCONF['DB']['host'], $MPCONF['DB']['username'], $MPCONF['DB']['password']); + if (!$db) { + $this->connected = 0; + return 0; + } else { + $this->identLink = $db; + $this->select_db($MPCONF['DB']['database']); + return $db; + } + } else { + return $this->identLink; + } } + function p_close() { + @mysql_close($this->identLink); + $this->identLink = 0; + } + function close() { @mysql_close($this->identLink); *************** *** 63,68 **** } ! function query($query) { global $MPCONF; if($this->identLink == 0) { $db = $this->connect(); --- 92,98 ---- } ! function query($query,$null='') { global $MPCONF; + $this->stats['query_count']++; if($this->identLink == 0) { $db = $this->connect(); *************** *** 76,85 **** else { // Execute query ! @mysql_select_db($MPCONF['DB']['database'], $db); ! $result = @mysql_query($query, $db) or die("MySQL Error: ".mysql_error($db)); } return $result; } function num_rows($query) { if($this->identLink == 0) { --- 106,133 ---- else { // Execute query ! $result = @mysql_query($query, $db) or die("MySQL Error: ".@mysql_error($db)); ! // $result = mysql_query($query, $db); } return $result; } + function select_db($db_name,$null='') { + global $MPCONF; + if($this->identLink == 0) { + $db = $this->connect(); + } else { + $db = $this->identLink; + } + if (!$db) { + $result = 0; + die("db connect error"); + } + else { + // Execute query + $result = @mysql_select_db($db_name, $db) or die("MySQL Error: ".@mysql_error($db)); + } + return $result; + } + function num_rows($query) { if($this->identLink == 0) { *************** *** 90,93 **** --- 138,161 ---- $num = @mysql_num_rows($query); return $num; + } + + function insert_id() { + if($this->identLink == 0) { + $db = $this->connect(); + } else { + $db = $this->identLink; + } + $num = @mysql_insert_id($this->identLink); + return $num; + } + + function result($result, $row, $field='') { + if($this->identLink == 0) { + $db = $this->connect(); + } else { + $db = $this->identLink; + } + $result = @mysql_result($result, $row, $field); + return $result; } |