<?php
abstract class mysql{
public $host;//主机地址
public $user;//用户名
public $passwd;
public $dbname;
public $charset;
function __construct($h,$u,$p,$d,$c){
$this->host=$h;
$this->user=$u;
$this->passwd=$p;
$this->dbname=$d;
$this->charset=$c;
$this->conn();
}
function conn(){
@mysql_connect($this->host,$this->user,$this->passwd) or die ("mysql连接失败");
@mysql_select_db($this->dbname) or die("数据库连接失败");
$this->q("set names '".$this->charset."'");
}
function q($n){
return mysql_query($n);
}
function id(){
return mysql_insert_id();
}
function f($n,$st=1){
switch($st){
case 1 :
$rs=mysql_fetch_array($n);
break;
case 2 :
$rs=mysql_fetch_row($n);
break;
}
return $rs;
}
//========================
/**
*说明:into插入数据库的方法
*参数:$tb表名,$val表示插入值,$st调试方式,1调试0不调试
*返回:int
*/
abstract function into($tb,$val,$st=0);
/**
*说明:sel_once查询
*参数:
$tb表名,
$wh条件默认1,
$ar制定的字段,
$ty查询类型,默认下标和键名,
$st调试状态,默认为0,1调试0不调试
*返回:array [一维数组]
*/
&