1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
<?php
class MysqlQueryResults implements ISqlQueryResults
{
private $Query_;
public function __construct( $query )
{
$this->Query = false;
if( is_resource($query) )
{
$this->Query_ = $query;
}
else
{
throw new Exception("L'argument fourni n'est pas une ressource !");
}
}
public function Next($type = "ASSOC")
{
switch($type)
{
case "ASSOC":
$res = mysql_fetch_array($this->Query_ ,MYSQL_ASSOC);
break;
case "NUM":
$res = mysql_fetch_array($this->Query_ , MYSQL_NUM);
break;
case "OBJECT":
$res = mysql_fetch_object($this->Query_);
break;
default:
$res = mysql_fetch_array($this->Query_ , MYSQL_BOTH);
break;
}
if( $res == false )
{
@mysql_free_result($this->Query_);
return false;
}
return $res;
}
public function Count()
{
if($this->Query_ != false)
{
return mysql_num_rows($this->Query_);
}
return -1;
}
public function __destruct()
{
@mysql_free_result($this->Query_);
unset($this->Query_);
}
}
?> |
Partager