<?php
//File db.class.inc.php
class db{
var $nienet_host='localhost';
var $nienet_user='username';
var $nienet_pass='passname';
var $nienet_db='dbname';
var $query_id;
}//end of db;
class connect extends db{
var $connect_id;
function my_pconnect(){
$query=new query;
// $this->connect_id= @mysql_connect($this->nienet_host, $this->nienet_user, $this->nienet_pass) or // die("Error: " . mysql_error());
// mysql_select_db($this->nienet_db,$this->connect_id);
// $user_id = strtolower($PHP_AUTH_USER);
if ($this->connect_id == 0) {
$this->connect_id = mysql_pconnect($this->nienet_host,$this->nienet_user,$this->nienet_pass);
if (!$this->connect_id) {
$query->my_halt("my_pconnect(" . $this->nienet_host . "," . $this->nienet_user . ",PASSWORD) failed.");
}
if (!@mysql_select_db($this->nienet_db,$this->connect_id)) {
$query->my_halt("Cannot connect to database ".$this->nienet_db);
return 0;
}
}
return $this->connect_id;
}//my_pconnect()
}//end of class connect;
class query extends db{
var $FirstName;
var $LastName;
var $email;
var $count;
var $result;
//var $q;
var $qid;
var $error = ""; // Error Message
var $errno = ""; // Error Number
function my_CREATE(){
$q = "CREATE TABLE product_price ( ";
$q .= " product_price_id int(11) DEFAULT '0' NOT NULL auto_increment,";
$q .= " vendor_id int(11) DEFAULT '0' NOT NULL,";
$q .= " product_id int(11) DEFAULT '0' NOT NULL,";
$q .= " group_id int(11),";
$q .= " product_price decimal(10,4),";
$q .= " product_currency char(16),";
$q .= " product_price_vdate int(11),";
$q .= " product_price_edate int(11),";
$q .= " cdate int(11),";
$q .= " mdate int(11),";
$q .= " PRIMARY KEY (product_price_id))";
$this->my_query($q);
mysql_close($connect->connect_id);
} //my_CREATE()
function my_insert(){
global $FirstName;
global $LastName;
global $email;
$this->count='1';
$this->FirstName=$FirstName;
$this->LastName=$LastName;
$this->email=$email;
$q = "INSERT INTO info ";
$q .= "VALUES('$this->FirstName','$this->LastName','$this->email',$this->count)";
$this->my_query($q);
mysql_close($connect->connect_id);
//echo $data_time;
} //my_insert()
function my_Select(){
$q = "SELECT * FROM info ";
$q .= "WHERE info.FirstName='fgf' AND info.email='bb@263.net'";
$this->my_query($q);
//mysql_close($connect->connect_id);
//echo $data_time;
} //my_Select()
function my_Update(){
$q = "Update info ";
$q .= "SET info.FirstName='' WHERE info.email='' and info.password='')";
$this->my_query($q);
mysql_close($connect->connect_id);
//echo $data_time;
} //my_Update()
function my_Delete(){
$q = "Delete FROM info ";
$q .= "WHERE info.email='')";
$this->my_query($q);
mysql_close($connect->connect_id);
//echo $data_time;
} //my_Delete()
function my_Select_query() {
$connect=new connect;
$connect->my_pconnect();
$obj3=new Select;
$obj3->my_Select();
if (empty($obj3->q))
return 0;
if (!$connect->my_pconnect()) {
return 0;
}
if ($this->qid) {
@mysql_free_result($this->qid);
$this->qid = 0;
}
$this->qid = @mysql_query($obj3->q, $connect->connect_id);
$this->row = 0;
$this->errno = mysql_errno();
$this->error = mysql_error();
if (!$this->qid) {
$this->my_halt("Invalid SQL: ".$obj3->q);
}
return $this->qid;
} //my_Select_query()
function my_query(&$q) {
$connect=new connect;
$connect->my_pconnect();
if (empty($q))
return 0;
if (!$connect->my_pconnect()) {
return 0;
}
if ($this->qid) {
@mysql_free_result($this->qid);
$this->qid = 0;
}
$this->qid = @mysql_query($q, $connect->connect_id);
$this->row = 0;
$this->errno = mysql_errno();
$this->error = mysql_error();
if (!$this->qid) {
$this->my_halt("Invalid SQL: ".$q);
}
return $this->qid;
} //my_query()
function my_next_record() {
$this->my_Select_query();
if (!$this->qid) {
$this->my_halt("next_record called with no query pending.");
return 0;
}
$num_fields = mysql_num_fields($this->qid);
echo '<hr>';
echo '<table border="1" cellpadding="0" cellspacing="0">';
echo '<caption align="center">'.$q.'</option>';
echo '<tr>';
for($i=0;$i<$num_fields;$i++) echo '<th>'.mysql_field_name($this->qid,$i).'</th>';
echo '</tr>';
while($row=mysql_fetch_row($this->qid)){
echo '<tr>';
for($i=0;$i<$num_fields;$i++) echo '<td>'.$row[$i].'</td>';
echo '</tr>';
}
echo '</table>';
$this->record = @mysql_fetch_array($this->qid);
$this->row += 1;
$this->errno = mysql_errno();
$this->error = mysql_error();
$stat = is_array($this->record);
return $stat;
}//my_next_record()
// Returns the number of rows in query
function my_num_rows() {
if ($this->lid) {
return @mysql_numrows($this->qid);
}
else {
return 0;
}
}//my_num_rows()
function my_halt($msg) {
$this->error = @mysql_error($connect->connect_id);
$this->errno = @mysql_errno($connect->connect_id);
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br>\n",
$this->errno,
$this->error);
exit;
} //my_halt()
}//end of class query;
class Select extends db{
function my_Select(){
//$query=new query;
$q = "SELECT * FROM info ";
$q .= "WHERE info.FirstName='fgf' AND info.email='bb@263.net'";
$this->q =$q;
//mysql_close($connect->connect_id);
//echo $data_time;
} //my_Select()
}//end of class Select;
$obj1=new query;
$obj1->my_next_record();
//$obj1->my_next_record();
?>
|