[phpMP-CVS] CVS: phpMP/includes/dba mssql.dba,NONE,1.1 mysql.dba,NONE,1.1
Status: Pre-Alpha
Brought to you by:
heimidal
|
From: Brian R. <hei...@us...> - 2003-06-30 01:44:10
|
Update of /cvsroot/phpmp/phpMP/includes/dba
In directory sc8-pr-cvs1:/tmp/cvs-serv2758/includes/dba
Added Files:
mssql.dba mysql.dba
Log Message:
Moving the dba directory into includes/.
--- 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/06/30 01:44:07 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/06/30 01:44:07 heimidal Exp $
*
*/
class DB
{
var $ident_link;
var $connected;
var $query_count;
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;
}
}
function close ()
{
if ( $this->ident_link != 0 )
{
@mysql_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 = @mysql_query( $qry, $db );
$this->query_count++;
return $result;
}
}
function num_rows ($query)
{
if ( $this->ident_link == 0 )
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
$num = @mysql_num_rows($query);
return $num;
}
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;
}
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;
}
function fetch_array($query)
{
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
return @mysql_fetch_array($query);
}
function fetch_assoc($query)
{
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
return @mysql_fetch_assoc($query);
}
function fetch_row($query)
{
if ( $this->ident_link == 0 )
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
$result = @mysql_fetch_row($query);
return $result;
}
function affected_rows() {
if($this->ident_link == 0)
{
$db = $this->connect();
}
else
{
$db = $this->ident_link;
}
return @mysql_affected_rows($db);
}
}
?>
|