[phpMP-CVS] CVS: phpMP/dba mysql.dba,1.16,1.17
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2002-11-05 22:11:08
|
Update of /cvsroot/phpmp/phpMP/dba In directory usw-pr-cvs1:/tmp/cvs-serv19025/dba Modified Files: mysql.dba Log Message: Complete rewrite has begun! Index: mysql.dba =================================================================== RCS file: /cvsroot/phpmp/phpMP/dba/mysql.dba,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** mysql.dba 27 Jul 2002 12:16:00 -0000 1.16 --- mysql.dba 5 Nov 2002 22:11:05 -0000 1.17 *************** *** 1,191 **** <?php ! /****************************************************************************** ! ******************************************************************************* ! ! phpMP - The World's Greatest Modular Portal ! *********************************************** ! Are you MPowered? ! ! Copyright (C) 2002 phpMP Development Group ! All rights reserved. ! ! Lead Programmer: Brian Rose ! Lead Designer: Trevor Joynson ! ! Filename: /dba/mysql.dba ! Usage & Function: DB Wrapper for MySQL ! Create Date: March 28, 2002 ! ! $Id$ ! ! ******************************************************************************* ! ******************************************************************************* ! ! This software is provided under the GPL software license. A copy of the ! license should have been included with this software, located in the Docs ! folder. Feel free to redistribute and/or modify it according to the ! regulations stated in the license. ! ! ******************************************************************************* ! ******************************************************************************* ! ! Notes on this document: ! Database abstraction classes have been partially taken from jimmacr's phpusion ! project. Some source code has been modified, but most functions do exactly ! the same thing he intended them for. Most likely, this code will be mostly ! rewritten by project release. ! ! ******************************************************************************* ! ******************************************************************************/ ! ! // Database Abstraction class - MySQL version ! //PERFORMS QUERIES ON A MYSQL DATABASE. ! class DBA{ ! ! 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; ! return 0; ! } 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); ! $this->identLink = 0; ! } ! ! function query($query,$null='') { ! global $MPCONF; ! $this->stats['query_count']++; ! if($this->identLink == 0) { ! $db = $this->connect(); ! } else { ! $db = $this->identLink; ! } ! if (!$db) { ! $result = 0; ! die("db connect error"); ! } ! else { ! // Execute query ! $result = @mysql_query($query, $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); ! } ! return $result; ! } ! ! function num_rows($query) { ! if($this->identLink == 0) { ! $db = $this->connect(); ! } else { ! $db = $this->identLink; ! } ! $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=0, $field='') { ! if($this->identLink == 0) { ! $db = $this->connect(); ! } else { ! $db = $this->identLink; ! } ! $result = @mysql_result($result, $row, $field); ! return $result; ! } ! ! function fetch_array($query) { ! if($this->identLink == 0) { ! $db = $this->connect(); ! } else { ! $db = $this->identLink; ! } ! return @mysql_fetch_array($query); ! } ! ! function fetch_row($query) { ! if($this->identLink == 0) { ! $db = $this->connect(); ! } else { ! $db = $this->identLink; ! } ! $result = @mysql_fetch_row($query); ! return $result; ! } ! ! function affected_rows() { ! if($this->identLink == 0) { ! $db = $this->connect(); ! } else { ! $db = $this->identLink; ! } ! return @mysql_affected_rows($db); ! } ! } ?> --- 1,5 ---- <?php ! // MySQL DB Layer. ?> |