Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class dblib_mysql
- {
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* ATTRIBUTES */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- var $connectionID;
- var $rows;
- var $dbname;
- var $dbuser;
- var $dbpass;
- var $dbhost;
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* CONSTRUCTOR */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function dblib_mysql ( $dbname, $dbuser, $dbpass, $dbhost )
- {
- $this -> dbname = $dbname;
- $this -> dbuser = $dbuser;
- $this -> dbpass = $dbpass;
- $this -> dbhost = $dbhost;
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* LOG ERROR */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function logError ( $theString )
- {
- $error = mysql_errno () . " : " . mysql_error ();
- generateLog ( "$error | $theString" );
- exit ( 1 );
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* OPEN A CONNECTION TO MYSQL DB */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function openDB ()
- {
- if ( !isset ( $GLOBALS [ 'openeddb' ] ) )
- {
- $this -> connectionID = mysql_connect ( $this -> dbhost, $this -> dbuser, $this -> dbpass );
- if ( !$this -> connectionID )
- $this->logError ( "Error openDB 1" );
- }
- else
- {
- $this -> connectionID = $GLOBALS [ 'openeddb' ];
- }
- generateLog ( "BD = " . $this -> dbname );
- $result = mysql_select_db ( $this -> dbname, $this -> connectionID );
- mysql_query("SET NAMES utf8");
- if ( !$result )
- $this->logError ( "Error openDB 2" );
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* CLOSE A CONNECTION TO MYSQL DB */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function closeDB ()
- {
- mysql_close ( $this -> connectionID );
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* RUN A QUERY */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function runQuery ( $query )
- {
- $this -> rows = mysql_query ( $query, $this -> connectionID );
- if ( !$this -> rows )
- $this->logError ( "Error runQuery [ $query ]" );
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* GET ROWS NUMBER */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function getRowsNumber ()
- {
- return ( mysql_num_rows ( $this -> rows ) );
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* FREE ROWS */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function freeRows ()
- {
- mysql_free_result ( $this -> rows );
- }
- /* -- -- -- -- -- -- -- -- -- -- -- */
- /* GET ROW */
- /* -- -- -- -- -- -- -- -- -- -- -- */
- function getRow ()
- {
- return ( mysql_fetch_array ( $this -> rows, MYSQL_BOTH ) );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement