Update of /cvsroot/phpgamedev/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26398
Added Files:
db_mysql.php
Log Message:
Initial commit of db_mysql file.
--- NEW FILE: db_mysql.php ---
<?php
//-----------------------------------------------------------
// FILENAME : db_mysql.php
// STARTED : Tue Jun 7, 2005
// AUTHOR : Sphen001 (Nick Ross)
// SUPPORT : http://phpgamedev.sourceforge.net
// COPYRIGHT : Copyright 2005 © PHPGameDev Group
// E-MAIL : Sphen001 -at- users -dot- sourceforge -dot- net
// $Id: db_mysql.php,v 1.6 2005/06/09 01:41:31 sphen001 Exp $
//-----------------------------------------------------------
if ( !defined( 'DB' ) )
{
define( 'DB', 'MySQL' );
}
class db
{
var $connect_id;
var $query_result;
var $query_rowset;
var $num_rows;
var $num_queries = 0;
function connect($db_host, $db_username, $db_password, $db, $persistent = FALSE)
{
if ( $this->connect_id = ( $persistent ) ? @mysql_pconnect($db_host, $db_username, $db_password) : @mysql_connect($db_host, $db_username, $db_password) )
{
if ( @mysql_select_db($db, $this->connect_id) )
{
return TRUE;
}
return FALSE;
}
return FALSE;
}
function disconnect()
{
if ( @mysql_close($this->connect_id) )
{
return TRUE;
}
return FALSE;
}
function query($query)
{
if ( $this->query_result = @mysql_query($query) )
{
$this->num_queries++;
return $this->query_result;
}
return FALSE;
}
function fetch_row($result, $type = 'ASSOC')
{
switch ( $type )
{
case 'ASSOC' :
if ( $this->query_rowset = @mysql_fetch_assoc($result) )
{
return $this->query_rowset;
}
return FALSE;
break;
case 'ARRAY' :
if ( $this->query_rowset = @mysql_fetch_array($result) )
{
return $this->query_rowset;
}
return FALSE;
break;
case 'OBJECT' :
if ( $this->query_rowset = @mysql_fetch_object($result) )
{
return $this->query_rowset;
}
return FALSE;
break;
case 'ROW' :
if ( $this->query_rowset = @mysql_fetch_row($result) )
{
return $this->query_rowset;
}
return FALSE;
break;
}
}
function num_rows($result)
{
if ( $this->num_rows = @mysql_num_rows($result) )
{
return $this->num_rows;
}
return FALSE;
}
function free_result($result)
{
@mysql_free_result($result);
return;
}
function num_queries()
{
return $this->num_queries;
}
function escape($sql)
{
return @mysql_escape_string($sql);
}
}
?>
|