PHP Classes

File: arbdb_mysql.php

Recommend this page to a friend!
  Classes of Paul Arbogast   arbplate   arbdb_mysql.php   Download  
File: arbdb_mysql.php
Role: ???
Content type: text/plain
Description: mysql abstraction for arbplate
Class: arbplate
Author: By
Last change:
Date: 23 years ago
Size: 3,537 bytes
 

Contents

Class file image Download
<? // // File: arbdb_mysql.php // Ver: 0.8a // Desc: mySql abstraction functions // Auth: Paul Arbogast // ******************* // Latest version is available at http://arbplate.sourceforge.net // Send Questions or comments to arbo@att.net // /* Copyright (C) 2001 Paul Arbogast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ class arbdb { var $_DB_TOK; var $_DB_RES; var $_CURRENT_DB = ""; var $_DB_HOST = ""; var $_DB_USER = ""; var $_DB_PASS = ""; // $dbid = new arbdb( databasename ); // function arbdb ( $argDb = "" ) { global $ARB_CONFIG; $this -> _DB_HOST = $ARB_CONFIG['DB_HOST'] ; $this -> _DB_USER = $ARB_CONFIG['DB_USER'] ; $this -> _DB_PASS = $ARB_CONFIG['DB_PASS'] ; if ( empty( $argDb ) ) { // if db name supplied, set _current_db so it will be selected automatically if ( ! ( empty( $ARB_CONFIG['DEF_DB'] ) ) ) { $this -> _CURRENT_DB = $ARB_CONFIG['DEF_DB']; } else { $this -> _CURRENT_DB = "" ; } } else { $this -> _CURRENT_DB = $argDB; } $this -> arbdb_open( ); } // internal - open connection and select db if provided // function arbdb_open ( ) { if ( ! ($this -> _DB_TOK = mysql_connect ( $this -> _DB_HOST , $this -> _DB_USER , $this -> _DB_PASS ) ) ) { trigger_error( "[MYSQL: " . mysql_error() . "]" , E_USER_ERROR ); } else { if ( ! ( empty( $this -> _CURRENT_DB ) ) ) { $this -> arbdb_select_db(); } } } // close database connection // function arbdb_close ( ) { if ( ! ( mysql_close ( $this -> _DB_TOK ) ) ) { trigger_error( "[MYSQL: " . mysql_error( $this -> _DB_TOK ) . "]" , E_USER_ERROR ); } } // select db // function arbdb_select_db ( ) { if ( ! ( mysql_select_db( $this -> _CURRENT_DB /*, $this -> _DB_TOK */ ) ) ) { echo $this -> _CURRENT_DB ; // trigger_error( "[MYSQL: " . mysql_error( $this -> _DB_TOK ) . "]" , E_USER_ERROR ); } } // query currently selected database // function arbdb_query ( $argQuery = "" ) { if ( ! ( $this -> _DB_RES = mysql_query ( $argQuery , $this -> _DB_TOK ) ) ) { trigger_error( "[MYSQL: " . mysql_error( $this -> _DB_TOK ) . "]" , E_USER_ERROR ); } } // get array of next row for current query results // function arbdb_next ( $rettype = "a" ) { if ( $rettype == "a" ) { return mysql_fetch_array ( $this -> _DB_RES , MYSQL_ASSOC ); } else { return mysql_fetch_array ( $this -> _DB_RES , MYSQL_NUM ); } } // get number of rows in last query result // function arbdb_num_rows ( ) { return mysql_num_rows( $this -> _DB_RES ); } } ?>