File: /home/asjudine/subdomains/correosasjudinet/httpdocs/bd.php
<?php
if (eregi("bd.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
class ResultSet {
var $result;
var $total_rows;
var $fetched_rows;
function set_result( $res ) {
$this->result = $res;
}
function get_result() {
return $this->result;
}
function set_total_rows( $rows ) {
$this->total_rows = $rows;
}
function get_total_rows() {
return $this->total_rows;
}
function set_fetched_rows( $rows ) {
$this->fetched_rows = $rows;
}
function get_fetched_rows() {
return $this->fetched_rows;
}
function increment_fetched_rows() {
$this->fetched_rows = $this->fetched_rows + 1;
}
}
function sql_connect($host, $user, $password, $db)
{
$dbi=@mysql_connect($host, $user, $password);
mysql_select_db($db);
return $dbi;
}
function sql_logout($id)
{
$dbi=@mysql_close($id);
return $dbi;
}
function sql_query($query, $id)
{
$res=@mysql_query($query, $id);
return $res;
}
function sql_do_connect($dbhost, $dbuname, $dbpass, $dbname)
{
$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
}
/*function sql_fetch_row(&$res)
{
$row = mysql_fetch_row($res);
return $row;
}*/
function sql_fetch_row(&$res, $nr)
{
$dbtype = "MySQL";
switch ($dbtype) {
case "MySQL":
$row = mysql_fetch_row($res);
return $row;
break;;
case "mSQL":
$row = msql_fetch_row($res);
return $row;
break;;
case "PostgreSQL":
case "PostgreSQL_local":
if( $res->get_total_rows() > $res->get_fetched_rows() ) {
$row = pg_fetch_row($res->get_result(), $res->get_fetched_rows() );
$res->increment_fetched_rows();
return $row;
} else {
return false;
}
break;;
case "ODBC":
case "ODBC_Adabas":
$row = array();
$cols = odbc_fetch_into($res, $nr, &$row);
return $row;
break;;
case "Interbase":
$row = ibase_fetch_row($res);
return $row;
break;;
case "Sybase":
$row = sybase_fetch_row($res);
return $row;
break;;
default:
break;;
}
}
function sql_fetch_array(&$res, $nr)
{
$row = array();
$row = mysql_fetch_array($res);
return $row;
}
function sql_num_rows($res)
{
$rows=mysql_num_rows($res);
return $rows;
}
function SQL_fetch_object(&$res, $nr)
{
$row = mysql_fetch_object($res);
if($row) return $row;
else return false;
}
$dbhost = "localhost";
$dbname = "correosasjudinet";
$dbuname = "correosasjudinet";
$dbpass = "asjudinet";
$prefix = "asjudinet";
$user_prefix = "asjudinet";
$dbtype = "MySQL";
global $dbi;
$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
?>