[phpMP-CVS] CVS: phpMP/core/dba index.html,NONE,1.1 mssql.dba,NONE,1.1 mysql.dba,NONE,1.1
Status: Pre-Alpha
Brought to you by:
heimidal
|
From: Brian R. <hei...@us...> - 2003-09-14 06:37:56
|
Update of /cvsroot/phpmp/phpMP/core/dba
In directory sc8-pr-cvs1:/tmp/cvs-serv9778/core/dba
Added Files:
index.html mssql.dba mysql.dba
Log Message:
This should be fun.
--- NEW FILE: index.html ---
<html>
<head>
<title>Sorry...</title>
</head>
<body>
This directory is not directly accessible.
</body>
</html>
--- NEW FILE: mssql.dba ---
<?php
/*
* phpMP - The PHP Modular Portal System
* Copyright (C) 2002-2003 Brian Rose and the phpMP group
*
* 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.
*
* $Id: mssql.dba,v 1.1 2003/09/14 06:37:53 heimidal Exp $
*
*/
class DB
{
var $ident_link;
var $connected;
function connect()
{
if (empty($this->ident_link))
{
$connection = @mssql_connect(DB_HOST, DB_USER, DB_PASSWD);
if (!$connection)
{
$this->connected = 0;
return 0;
}
else
{
$this->ident_link = $connection;
return $this->ident_link;
}
}
}
function close()
{
if ($this->ident_link != 0)
{
@mssql_close($this->ident_link);
$this->ident_link = 0;
return 1;
}
else
{
return 1;
}
}
function query($qry)
{
if ($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
if (!$db)
{
return 0;
}
else
{
$result = @mssql_query($qry, $db);
return $result;
}
}
function num_rows($qry)
{
if ($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
if (!$db)
{
return 0;
}
else
{
$num = @mssql_num_rows($qry);
return $num;
}
}
function result($result, $row=0, $field='')
{
if ($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
if (!$db)
{
return 0;
}
else
{
$return = @mssql_result($result, $row, $field);
return $return;
}
}
function fetch_array($qry)
{
if ($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
if (!$db)
{
return 0;
}
else
{
$result = @mssql_fetch_array($qry);
return $result;
}
}
function fetch_row($qry)
{
if ($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
if (!$db)
{
return 0;
}
else
{
$result = @mssql_fetch_row($qry)
return $result;
}
}
function escape_string($string)
{
if( stripslashes($string) == $string ) // Will be true if no slashes were removed.
{
addslashes($string); // We'll add the slashes because they haven't already been added.
return true;
}
else // Slashes have already been added (hopefully only once).
{
return true;
}
}
}
?>
--- NEW FILE: mysql.dba ---
<?php
/*
* phpMP - The PHP Modular Portal System
* Copyright (C) 2002-2003 Brian Rose and the phpMP group
*
* 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.
*
* $Id: mysql.dba,v 1.1 2003/09/14 06:37:53 heimidal Exp $
*
*/
class DB
{
var $ident_link;
var $connected;
var $query_count;
/**
* @return int
* @desc Connects to a MySQL server.
*/
function connect()
{
if ( empty ($this->ident_link) )
{
$connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWD);
if ( !$connection )
{
$this->connected = 0;
return 0;
}
else
{
$this->ident_link = $connection;
return $this->ident_link;
}
}
else
{
return $this->ident_link;
}
}
/**
* @return int
* @desc Closes the connection to a MySQL server.
*/
function close()
{
if ( $this->ident_link != 0 )
{
@mysql_close($this->ident_link);
$this->ident_link = 0;
return 1;
}
else
{
return 1;
}
}
/**
* @return int
* @param qry string
* @desc Performs a query on the MySQL server.
*/
function query($qry)
{
if ( $this->ident_link == 0 )
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
if ( !$db )
{
return 0;
}
else
{
$result = @mysql_query( $qry, $db );
$this->query_count++;
return $result;
}
}
/**
* @return int
* @param query string
* @desc Container for mysql_num_rows().
*/
function num_rows($query)
{
if ( $this->ident_link == 0 )
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
$num = @mysql_num_rows($query);
return $num;
}
/**
* @return int
* @desc Container for mysql_insert_id().
*/
function insert_id()
{
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
$num = @mysql_insert_id($this->ident_link);
return $num;
}
/**
* @return mixed
* @param result int
* @param row int
* @param field string
* @desc Container for mysql_result().
*/
function result( $result, $row=0, $field='' )
{
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
$result = @mysql_result($result, $row, $field);
return $result;
}
/**
* @return array
* @param query int
* @desc Container for mysql_fetch_array().
*/
function fetch_array($query)
{
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
return @mysql_fetch_array($query);
}
/**
* @return array
* @param query int
* @desc Container for mysql_fetch_assoc().
*/
function fetch_assoc($query)
{
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
return @mysql_fetch_assoc($query);
}
/**
* @return array
* @param query int
* @desc Container for mysql_fetch_row().
*/
function fetch_row($query)
{
if ( $this->ident_link == 0 )
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
$result = @mysql_fetch_row($query);
return $result;
}
/**
* @return int
* @desc Container for mysql_affected_rows().
*/
function affected_rows() {
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
return @mysql_affected_rows($db);
}
}
?>
|