class dbcore
{
var $dblink, $dbhost, $dbuser, $dbpass, $dbname, $link, $Errno, $Error;
function dbcore()
{
global $db_org;
$this->getdblinks($db_org);
}
function getdblinks($pm_dbvars)
{
$this->dbhost = $pm_dbvars["dbhost"];
$this->dbuser = $pm_dbvars["dbuser"];
$this->dbpass = $pm_dbvars["dbpass"];
$this->dbname = $pm_dbvars["dbname"];
}
function setdblinks($pm_dblink, $pm_dbhost, $pm_dbuser, $pm_dbpass, $pm_dbname)
{
$this->dbhost = $pm_dbhost;
$this->dbuser = $pm_dbuser;
$this->dbpass = $pm_dbpass;
$this->dbname = $pm_dbname;
}
function siri_open()
{
$t_link = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
if(!$t_link){
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->error("Unable to Connect the Server".$this->dbhost);
}
$bool = mysql_select_db($this->dbname);
if(!$bool){
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->error("Database Not Found :".$this->dbname);
}
return $t_link;
break;
}
function siri_query($my_qry)
{
$this->link = $this->siri_open();
$qid = mysql_query ($my_qry, $this->link);
$this->siri_close($this->link);
if(!$qid){
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->error("Problem In Executing the Query:" . $my_qry);
}
return $qid;
}
function siri_count($my_qry)
{
// returns the count value.
$this->link = $this->siri_open();
$qid = mysql_query ($my_qry, $this->link);
$this->siri_close($this->link);
if(!$qid){
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->error("Problem In Executing the Query:" . $my_qry);
}
$count = $this->siri_fetch_array($qid);
return $count[0];
}
function siri_fetch_array($qid)
{
return @mysql_fetch_array($qid);
}
function siri_fetch_row($qid) {
return mysql_fetch_row($qid);
}
function siri_fetch_object($qid) {
return @mysql_fetch_object($qid);
}
function siri_num_rows($qid) {
return @mysql_num_rows($qid);
}
function siri_affected_rows() {
// for insert, update, delete reasons.
return mysql_affected_rows();
}
function siri_insert_id() {
return mysql_insert_id($link);
}
function siri_insert_id1() {
return mysql_insert_id();
}
function siri_free_result($qid) {
mysql_free_result($qid);
}
function siri_num_fields($qid) {
return mysql_num_fields($qid);
}
function siri_close($link)
{
mysql_close($link);
}
function error($msg) {
// printf("Error : %s
\n", $msg);
// printf("MySQL Error: %s (%s)
\n", $this->Errno, $this->Error);
}
function siri_fquery($qry,$val)
{
$qid = $this->siri_query($qry);
while($re = $this->siri_fetch_array($qid))
{
print"\n";
}
}
function siri_sinvalue($qry)
{
$qid = $this->siri_query($qry);
$rs = $this->siri_fetch_array($qid);
return $rs[1];
}
function redirect($page)
{
if(!headers_sent())
header("location:$page");
else
echo "";
}
function siri_drawNavigation($start,$total,$link)
{
if(($start%100)==0)
{
$j=$start/10+1;
}
else if($start/100>=1){
$j=intval(($start/100))*10+1;
}
else
{
$j=1;
}
if((intval($start/100))>1)
{
$temp=intval(($start/100-1))*10*10;
}
print "
";
global $len;
$check=$total%$len;
if($check >=1 ) $lim=intval(($total/$len))+1;
else
$lim=intval($total/$len);
print "
| ";
$en = $start +$len;
// if($start==0 && $total>0){$start1=1;} else {$start1 = $start+1;}
if($start==0){
if($total>0){
$start1=1;
}
else {
$start1=0;
}
}
else {
$start1=$start+1;
}
if($en>$total)
$en = $total;
print "Showing $start1 - $en of $total Go to First Record | " ;
if($en>$len)
{
$en1=$start-$len;
print "Previous" ;
}
else
print "Previous";
print "";
$temp1=1;
print " " ;
if($en<$total){
$en2=$start+$len;
print "Next" ;
}
else
print "Next";
print " |
|
";
}
function shrstr($string, $num="50") {
// Check string length if grater then $num
if (strlen($string) > $num) {
// Shorten the string with ...
$string = substr( $string, 0, $num-2);
$string .= "...";
return $string;
} else {
// If $num is less then
return $string;
}
}
////////////////////////////////
function siri_insert_query($my_qry)
{
$this->link = $this->siri_open();
$qid = mysql_query ($my_qry, $this->link);
$lid = mysql_insert_id($this->link);
$this->siri_close($this->link);
if(!$qid){
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->error("Problem In Executing the Query:" . $my_qry);
}
return $lid;
}
}// end of the class
?>