<?php
/*
More & Original PHP Framwork
Copyright (c) 2007 - 2008 IsMole Inc.
$Id: Mysql.Class.php 2008-3-19 aming$
*/
class MooMySQL
{
var $queryCount = 0;
var $conn;
var $result;
var $rsType = MYSQL_ASSOC;
//note:查询时间
var $queryTimes = 0;
/**
* 连接数据库
*
* @param string $dbhost
* @param string $dbdata
* @param string $dbuser
* @param string $dbpass
* @param blooean $dbOpenType
* @param string $dbcharset
*/
function connect($dbhost = '', $dbuser = '', $dbpass = '', $dbdata = '', $dbOpenType = false ,$dbcharset = 'utf8') {
if($dbOpenType) {
} else {
}
$mysql_version = $this->getMysqlVersion();
if($mysql_version > '4.1') {
global $charset, $dbcharset;
$dbcharset = $dbcharset2 ? $dbcharset2 : $dbcharset;
$serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary' : '';
$serverset .= $mysql_version > '5.0.1' ?
((empty($serverset) ?
'' : ',').'sql_mode=\'\'') : '';
$serverset && mysql_query("SET $serverset", $this->conn);
}
}
/**
* 关闭数据库连接,当您使用持续连接时该功能失效
*
*/
function close() {
}
/**
* 发送查询语句
*
* @param string $sql
* @param string $type
* @return blooean
*/
function query($sql, $type = "ASSOC") {
$this->rsType = $type != "ASSOC" ? ($type == "NUM" ? MYSQL_NUM : MYSQL_BOTH) : MYSQL_ASSOC;
$this->queryCount++;
if($this->result) {
return $this->result;
} else {
return false;
}
}
/**
* 数据量比较大的情况下查询
*
* @param string $sql
* @param string $type
* @return blooean
*/
function bigQuery($sql, $type = "ASSOC") {
$this->rsType = $type != "ASSOC" ? ($type == "NUM" ? MYSQL_NUM : MYSQL_BOTH) : MYSQL_ASSOC;
$this->queryCount++;
if($this->result) {
return $this->result;
}
else {
return false;
}
}
/**
* 获取全部数据
*
* @param string $sql
* @param blooean $nocache
* @return array
*/
function getAll($sql = "", $nocache = false) {
if($sql) {
if($nocache) {
$this->bigQuery($sql);
} else {
$this->query($sql);
}
}
$rows[] = $row;
}
return $rows;
}
/**
* 获取单行数据
*
* @param string $sql
* @return array
*/
function getOne($sql = "") {
if($sql) {
$this->query($sql);
}
return $rows;
}
/**
* mysql_fetch_array
*
* @param string $sql
* @return
*/
function fetchArray($query) {
}
/**
* 取得上一步 INSERT 操作产生的 ID
*
* @param string $sql
* @return integer
*/
function insertId($sql = "") {
if($sql) {
$row = $this->getOne($sql);
return $row;
} else {
}
}
function insert($sql) {
$this->result = $this->query($sql);
$id = $this->insertId();
return $id;
}
/**
* 取得行的数目
*
* @param string $sql
* @return integer
*/
function numRows($sql = "") {
if($sql) {
$this->query($sql);
}
return $row;
}
/**
* 取得结果集中字段的数目
*
* @param string $sql
* @return integer
*/
function numFields($sql = "") {
if($sql) {
$this->query($sql);
}
}
/**
* 取得结果中指定字段的字段名
*
* @param string $data
* @param string $table
* @return array
*/
function listFields($data, $table) {
for($i = 0; $i < $count; $i++) {
}
return $rows;
}
/**
* 列出数据库中的表
*
* @return array
*/
function listTables($data) {
$rows[] = $row[0];
}
return $rows;
}
/**
* 取得表名
*
* @param string $table_list
* @param integer $i
* @return string
*/
function tableName($table_list, $i) {
}
/**
* 转义字符串用于查询
*
* @param string $char
* @return string
*/
function escapeString($char) {
if(!$char) {
return false;
}
}
/**
* 取得数据库版本信息
*
* @return string
*/
function getMysqlVersion() {
}
}