复制代码 代码如下:

$name; return null; } public function
connect($host,$user,$pass,$db,$charSet=’utf8′,$force=false) {
if($this->db && ($this->db instanceof mysqli) && !$force) { return
; } $this->db=new mysqli($host,$user,$pass,$db); if
(mysqli_connect_error { die(‘Connect Error (‘ . mysqli_connect_errno
‘ . mysqli_connect_error; } $this->db->set_charset; } //$dbname
string //再次回到值 借使成功则赶回 TRUE,失利则赶回 FALSE。 function
select_db { return $this->db->select_db; } //$query
mysqli_result //$resulttype int MYSQLI_ASSOC, MYSQLI_NUM, or
MYSQLI_BOTH. Defaults to MYSQLI_BOTH. //返回值 Returns an array of
strings that corresponds to the fetched row or NULL if there are no more
rows in resultset. function fetch_array(/*mysqli_result*/ $query,
$resulttype = MYSQLI_ASSOC) { //var_dump; if(!$query || !($query
instanceof mysqli_result)) return NULL; return
$query->fetch_array;// } function data_seek { return
$result->data_seek; } function fetch_assoc { return
$query->fetch_assoc();// 关联数组 } function fetch_row { return
$query->fetch_row();// 索引数组,数字0,1。eg。。。 } function
fetch_fields { return $query->fetch_田野先生s(); } //$query string
//$resultmode int //再次来到值 尽管成功则赶回 TRUE,失败则赶回 FALSE。 For
SELECT, SHOW, DESCSportageIBE or EXPLAIN mysqli_query() will return a result
object. public function query($sql ,$resultmode=MYSQLI_STORE_RESULT )
{ if { $sqlstarttime = $sqlendttime = 0; $mtime = explode; $sqlstarttime
= $mtime[1]+ $mtime[0] ; } //真正查询 $query=$this->db->query;
if { // sleep; $mtime = explode; $sqlendttime = $mtime[1] +
$mtime[0] ; $sqlQueryTime = number_format($sqlendttime –
$sqlstarttime,6); //dblogs($sql, $sqlQueryTime,1); $explain = array();
$info = $this->db->info; if($query && preg_match/i”, $sql)) {
$explain = $this->fetch_array($this->db->query, MYSQLI_ASSOC
); } $GLOBALS[‘mysql_debug_query’][] = array(‘sql’=>$sql,
‘time’=>$sqlQueryTime, ‘info’=>$info, ‘explain’=>$explain); }
if { $this->halt(‘MySQL Query Error’, $sql); } return $query; }
//返回值 mysqli_stmt对象 function prepare { return
$this->db->prepare; } function affected_rows() { return
$this->db->affected_rows; } function error() { return
$this->db->error; } function errno() { return
$this->db->errno; } //result 没有 function num_rows { return
$query->num_rows; } //再次来到值 int The number of 田野s from a result
set. //也足以用其余意气风发种形式 mysqliHelp->db->田野同志_count返回。
function num_fields { return $query->field_count; } function
free_result { //all methods are equivalent; $query->free();
//$query->free_result; } function insert_id() { if(($id =
$this->db->insert_id)>= 0) { return $id; }else {
$idArr=$this->fetch_array($this->query(“SELECT last_insert_id;
return intval; } //return
($idArr=$this->fetch_array($this->query(“SELECT
last_insert_id[0] //return ($id = $this->db-insert_id)>= 0 ?
$id : 0 ; } function close() { return $this->db->close(); }
function halt { $dberror = $this->error(); $dberrno =
$this->errno(); $help_link =
“;
echo “

mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if(mysqli_connect_errno { $this->mysqli = false; echo ‘

MySQL Error
Message: $message
SQL: $sql
Error: $dberror
Errno.: $dberrno
Click here to seek
help.

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注