- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
class MysqlResultSet implements Iterator{
private $strSQL;
private $databasename;
private $connection;
private $result;
private $valid;
private $currentrow;
private $key;
const INDETERMINATE_TOTAL_NUMBER = 5001;
const UNNECESSARY_SQL_CALC_FOUND_ROWS = 5002;
const NOT_SELECT_QUERY = 5003;
public function __construct( $strSQL, $databasename, $connection ){
$this->strSQL = $strSQL;
$this->connection = $connection;
$this->databasename = $databasename;
if(!mysql_selectdb($databasename, $connection)){
throw new MySQLException(mysql_error(), mysql_errno());
}
if(!$this->result = mysql_query($strSQL, $connection)){
throw new MySQLException(mysql_error(), mysql_errno());
}
if (stristr($strSQL,"SQL_CALC_FOUND_ROWS")){
$msg = "No need to use SQL_CALC_FOUND_ROWS.";
throw new MySQLException($msg, self::UNNECESSARY_SQL_CALC_FOUND_ROWS);
}
$this->rewind();
}
public function __destruct(){
$this->close();
}
public function __call($name, $args){
$args = null;
$name = "mysql_". $name;
if(function_exists($name)){
return call_user_func_array($name, $args);
}
}
# Ну и так далее...
31-38 строки: Не понятно, зачем нужно было вообще этот класс писать?!
32-ая строка вообще сногсшибательна... (P.S. Из одной book по ООП в PHP5)