Update of /cvsroot/phpgamedev/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22649
Added Files:
db_mysql.php
Log Message:
Initial commit of MySQL DB layer.
--- 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.1 2005/06/08 01:38:38 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;
function connect($db_host, $db_username, $db_password, $db)
{
if ( $this->connect_id = @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) )
{
return $this->query_result;
$this->num_queries++;
}
return FALSE;
}
function fetchrow($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;
}
}
?>
|