<?php
/*
* class amd methods for retrieve records form mysql database and tables
*
* ajay kumar prasad (ajai)
* copyright 2010
* http://solutionsinfini.com
*/
?> <?php
include_once('connectDatabase.php');
class fetcht4rmTable extends DBConnect
{
public $tablename , $fields , $where , $values , $sql, $orderby, $limit;
function fetchdetails($table,$fields,$where,$values)
{
$this->tablename=$table;
$this->fields=$fields;
$this->where=$where;
$this->values=$values;
$this->sql="SELECT ". $this->fields ." FROM ". $this->tablename;
if($where!="")
$this->sql.=" WHERE ". $this->where ."='". $this->values."'";
// echo $this->sql;
$q=mysql_query($this->sql) or die(mysql_error());
while($f=mysql_fetch_assoc($q))
{
$result[]=$f;
}
return $result;
}
function fetchdetailsorderby($table,$fields,$where,$values,$orderby,$limit)
{
$this->tablename=$table;
$this->fields=$fields;
$this->where=$where;
$this->values=$values;
$this->orderby=$orderby;
$this->limit=$limit;
$this->sql="SELECT ". $this->fields ." FROM ". $this->tablename;
if($this->where!="")
$this->sql.=" WHERE ". $this->where ."='". $this->values."'";
if($this->orderby!="")
$this->sql.=" ORDER BY ". $this->orderby;
if($this->limit!="")
$this->sql.= $this->limit;
$q=mysql_query($this->sql);
while($f=mysql_fetch_assoc($q))
{
$result[]=$f;
}
return $result;
}
function fetchdetailsMorecondition($table , $fields , $params, $lOpr)
{
$this->tablename=$table;
$this->fields=$fields;
$this->sql="SELECT ". $this->fields ." FROM ". $this->tablename;
if(count($params)>0)
{
$i=0;
$this->sql.=" WHERE ";
while($i<count($params))
{
$this->sql.= $params[$i][0] ."='". $params[$i][1]."' ";
if($params[$i+1][0]!="")
$this->sql.=$lOpr. ' ' ;
$i++;
}
}
//echo $this->sql;
$q=mysql_query($this->sql);
while($f=mysql_fetch_assoc($q))
{
$result[]=$f;
}
return $result;
}
function fetchdetails4rmMultiplletable($tables,$fields,$relwhere,$orderBy)
{
$this->tablename=$tables;
$this->fields=$fields;
$this->where=$relwhere;
$this->orderby=$orderBy;
$this->sql="SELECT ". $this->fields ." FROM ". $this->tablename. $this->where . $this->orderby ;
//echo $this->sql;
$q=mysql_query($this->sql);
while($f=mysql_fetch_assoc($q))
{
$result[]=$f;
}
return $result;
}
}
?>
|