MySQL Database link Query class
Class Mysqlquery
{
var $sql;//sql Statement Execution results
var $query;//sql statement
var $num//return number of records
var $r;//return array
var $id//Return database ID number
Execute mysql_query () statement
function query ($query)
{
$this->sql=mysql_query ($query) or Die (mysql_error
()." <br> ". $query);
return $this->sql;
}
Execute mysql_query () Statement 2
function Query1 ($query)
{
$this->sql=mysql_query ($query);
return $this->sql;
}
Execute mysql_fetch_array ()
function Fetch ($SQL)//The parameter of this method is $sql is the result of SQL statement execution
{
$this->r=mysql_fetch_array ($sql);
return $this->r;
}
Executive Fetchone (Mysql_fetch_array ())
The difference between this method and fetch () is: 1, the parameter of this method is $query is the SQL statement
2, this method is used while (), the for () database pointer does not automatically move down, and fetch () can be from
Move Down.
function fetch1 ($query)
{
$this->sql= $this->query ($query);
$this->r=mysql_fetch_array ($this->sql);
return $this->r;
}
//executes mysql_num_rows ()
function num ($query)//The parameter of this class is $query is the SQL statement
{
$ This->sql= $this->query ($query);
$this->num=mysql_num_rows ($this->sql);
return $this->num;
}
//Execution Numone (mysql_num_rows ())
//The difference between this method and Num () is: 1, the parameter of this method is $sql is the execution result of the SQL statement
。
function Num1 ($sql)
{
$this->num=mysql_num_rows ($sql);
return $this->num;
}
Executive Numone (Mysql_num_rows ())
Number of statistical records
function Gettotal ($query)
{
$this->r= $this->fetch1 ($query);
Return $this->r[' Total '];
}
Execute free (mysql_result_free ())
The parameter of this method is $sql is the result of the execution of the SQL statement. Only in the use of
In the case of Mysql_fetch_array
function free ($sql)
{
Mysql_free_result ($sql);
}
Execute Seek (Mysql_data_seek ())
The parameter of this method is $sql is the result of the execution of the SQL statement, $pit the offset of the execution pointer
function Seek ($sql, $pit)
{
Mysql_data_seek ($sql, $pit);
}
Execution ID (mysql_insert_id ())
function LastID ()//Get last execution MySQL database ID number
{
$this->id=mysql_insert_id ();
return $this->id;
}
}