mirror of
https://github.com/Xkeeper0/jul.git
synced 2025-05-19 08:40:21 -07:00
Making mysql trigger_error on query failure
This commit is contained in:
parent
ce7da5ee40
commit
8d659c0958
@ -1,57 +1,55 @@
|
|||||||
<?php
|
<?php
|
||||||
class mysql{
|
class mysql{
|
||||||
var $queries=0;
|
var $queries=0;
|
||||||
var $rowsf=0;
|
var $rowsf=0;
|
||||||
var $rowst=0;
|
var $rowst=0;
|
||||||
var $time=0;
|
var $time=0;
|
||||||
function connect($host,$user,$pass) {return mysql_connect($host,$user,$pass);}
|
function connect($host,$user,$pass) {return mysql_connect($host,$user,$pass);}
|
||||||
function selectdb($dbname) {return mysql_select_db($dbname);}
|
function selectdb($dbname) {return mysql_select_db($dbname);}
|
||||||
|
|
||||||
function query($query){
|
function query($query){
|
||||||
// if($_GET[q])
|
$start=microtime(true);
|
||||||
// print "$query<br>";
|
if($res=mysql_query($query)){
|
||||||
$start=microtime(true);
|
$this->queries++;
|
||||||
if($res=mysql_query($query)){
|
$this->rowst+=@mysql_num_rows($res);
|
||||||
$this->queries++;
|
} else {
|
||||||
$this->rowst+=@mysql_num_rows($res);
|
trigger_error("MySQL error: ". mysql_error(), E_USER_WARNING);
|
||||||
} else {
|
}
|
||||||
// print mysql_error();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->time+=microtime(true)-$start;
|
$this->time+=microtime(true)-$start;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch($result){
|
function fetch($result){
|
||||||
$start=microtime(true);
|
$start=microtime(true);
|
||||||
|
|
||||||
if($result && $res=mysql_fetch_array($result, MYSQL_ASSOC))
|
if($result && $res=mysql_fetch_array($result, MYSQL_ASSOC))
|
||||||
$this->rowsf++;
|
$this->rowsf++;
|
||||||
|
|
||||||
$this->time+=microtime(true)-$start;
|
$this->time+=microtime(true)-$start;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($result,$row=0,$col=0){
|
function result($result,$row=0,$col=0){
|
||||||
$start=microtime(true);
|
$start=microtime(true);
|
||||||
|
|
||||||
if($result && $res=@mysql_result($result,$row,$col))
|
if($result && $res=@mysql_result($result,$row,$col))
|
||||||
$this->rowsf++;
|
$this->rowsf++;
|
||||||
|
|
||||||
$this->time+=microtime(true)-$start;
|
$this->time+=microtime(true)-$start;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchq($query,$row=0,$col=0){
|
function fetchq($query,$row=0,$col=0){
|
||||||
$res=$this->query($query);
|
$res=$this->query($query);
|
||||||
$res=$this->fetch($res);
|
$res=$this->fetch($res);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resultq($query,$row=0,$col=0){
|
function resultq($query,$row=0,$col=0){
|
||||||
$res=$this->query($query);
|
$res=$this->query($query);
|
||||||
$res=$this->result($res,$row,$col);
|
$res=$this->result($res,$row,$col);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user