functionquery($sql, $type = '') {
if ($this->link_id === NULL) {
$this->connect($this->settings['dbhost'], $this->settings['dbuser'], $this->settings['dbpw'], $this->settings['dbname'], $this->settings['charset'], $this->settings['pconnect']); $this->settings = array(); }
if ($this->queryCount++ <= 99) {
$this->queryLog[] = $sql; }
if ($this->queryTime == '') {
if (PHP_VERSION>= '5.0.0') {
$this->queryTime = microtime(true); } else
{
$this->queryTime = microtime(); } }
/* 当当前的时间大于类初始化时间的时候,自动执行 ping 这个自动重新连接操作 */ if (time() >$this->starttime + 1) {
$this->link_id->ping(); }
if(!($query = $this->link_id->query($sql)) &&$type != 'SILENT') {
$this->error_message[]['message'] = 'MySQL Query Error'; $this->error_message[]['sql'] = $sql;
$this->error_message[]['error'] = $this->link_id->error; $this->error_message[]['errno'] = $this->link_id->errno;
$this->ErrorMsg();
returnfalse; }
if (defined('DEBUG_MODE') && (DEBUG_MODE & 8) == 8)
{
$logfilename = $this->root_path . DATA_DIR . '/mysql_query_' .$this->dbhash . '_' . date('Y_m_d') . '.log'; $str = $sql . \
if (PHP_VERSION>= '5.0') {
file_put_contents($logfilename, $str, FILE_APPEND); } else
{
$fp = @fopen($logfilename, 'ab+'); if ($fp)
{ fwrite($fp, $str); fclose($fp); } } }
return$query; }
functionaffected_rows() {
return$this->link_id->affected_rows; }
functionerror() {
return$this->link_id->error; }
functionerrno() {
return$this->link_id->errno; }
functionresult($query, $row) {
$query->data_seek($row); $result = $query->fetch_row(); $query->free(); return$result; }
functionnum_rows($query) {
return$query->num_rows; }
functionnum_fields($query) {
return$this->link_id->field_count; }
functionfree_result($query) {
return$query->free(); }
functioninsert_id() {
return$this->link_id->insert_id; }
functionfetchRow($query) {
return$query->fetch_assoc(); }
functionfetch_fields($query) {
return$query->fetch_field(); }
functionversion() {
return$this->version; }
functionping() {
return$this->link_id->ping(); }
functionescape_string($unescaped_string) {
return$this->link_id->real_escape_string($unescaped_string);
}
functionclose() {
return$this->link_id->close(); }
functionErrorMsg($message = '', $sql = '') { if ($message) {
echo \$message\\n\\n
\//print('
href=\QL server on\ } else {
echo \print_r($this->error_message);
//echo \
$this->error_message[3]['errno'] . \target='_blank'>http://faq.comsenz.com/\ } exit; }
/* 仿真Adodb函数 */
functionselectLimit($sql, $num, $start = 0) { if ($start == 0) {
$sql .= ' LIMIT ' . $num; } else {
$sql .= ' LIMIT ' . $start . ', ' . $num; }
return$this->query($sql); }
functiongetOne($sql, $limited = false)
{
if ($limited == true) {
$sql = trim($sql . ' LIMIT 1'); }
$res = $this->query($sql); if ($res !== false) {
$row = $res->fetch_row(); $res->free(); if ($row !== false) { return$row[0]; } else
{ return ''; } } else { returnfalse; } }
functiongetOneCached($sql, $cached = 'FILEFIRST') {
$sql = trim($sql . ' LIMIT 1');
$cachefirst = ($cached == 'FILEFIRST' || ($cached == 'MYSQLFIRST' &&$this->platform != 'WINDOWS')) &&$this->max_cache_time; if(!$cachefirst) {
return$this->getOne($sql, true); } else {
$result = $this->getSqlCacheData($sql, $cached); if (empty($result['storecache']) == true) { return$result['data']; } }
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库ecshop适应PHP7的修改(2)在线全文阅读。
相关推荐: