<?php
/*####################################################################
## Class Name : my_sql ##
## Description : used as basic operation on mysql database ##
## Function : my_sql, query, fetch, numrows ##
## ##
## Created On : March 17, 2004 ##
## Last Modified : March 17, 2004 ##
####################################################################*/
class my_sql
{
var $hostname;
var $username;
var $password;
var $dbase;
var $sql_result;
var $sql_conn;
var $sql_data;
/***********************************************************
** Function: my_sql
** Description: constructor for attribute initialization
** and database connection
***********************************************************/
function my_sql() //constructor
{
$this->hostname = "localhost";
$this->username = "root";
$this->password = "password";
$this->dbase = "pss_project";
$this->sql_conn = mysql_connect($this->hostname,$this->username,$this->password);
if($this->sql_conn){
mysql_select_db($this->dbase);
}else{
echo mysql_error();
}
}
/***********************************************************
** Function: query
** Description: process query from uer input
** Parameter: $str_query => SQL command
***********************************************************/
function query($str_query)
{
$this->sql_result = mysql_query($str_query,$this->sql_conn);
return $this->sql_result;
}
/***********************************************************
** Function: fetch
** Description: return recordset from query
** Parameter: none
***********************************************************/
function fetch()
{
$this->sql_data = mysql_fetch_array($this->sql_result);
return $this->sql_data;
}
/***********************************************************
** Function: numrows
** Description: return number of record inside recordset
** Parameter: none
***********************************************************/
function numrows()
{
$num_row = mysql_num_rows($this->sql_result);
return $num_row;
}
}
?>