mysqlInterface.php

Go to the documentation of this file.
00001 <?php
00002 
00003 class mysqlInterface {
00004     private $resource = null;
00005     private $queries = array();
00006     private $qcursor = 0;
00007 
00008     public function __construct () {
00009     }
00010 
00011     public function connect ($host, $user, $pass, $db) {
00012         if ($this->resource = @mysql_connect( $host, $user, $pass ) AND mysql_select_db($db)) return $this->resource;
00013         return null;
00014     }
00015 
00016     public function connectError () {
00017         return mysql_error();
00018     }
00019 
00020     public function setCharset ($charset) {
00021         mysql_query ("SET CHARSET '$charset'");
00022     }
00023 
00024     public function query ($sql) {
00025         $this->cursor = mysql_query ($sql);
00026         return $this->cursor;
00027     }
00028 
00029     public function errno () {
00030         return mysql_errno();
00031     }
00032     
00033     public function error () {
00034         return mysql_error();
00035     }
00036 
00037     public function getEscaped($text) {
00038         return mysql_real_escape_string ((string) $text);
00039     }
00040 
00041     public function getNumRows ($cur=null) {
00042         return mysql_num_rows( $cur ? $cur : $this->cursor );
00043     }
00044 
00045     public function getAffectedRows () {
00046         return mysql_affected_rows();
00047     }
00048 
00049     public function insertid() {
00050         return mysql_insert_id($this->resource);
00051     }
00052 
00053     public function getVersion() {
00054         return mysql_get_server_info();
00055     }
00056 
00057     public function getFetchFunc() {
00058         return 'mysql_fetch_';
00059     }
00060 
00061     public function freeResultSet ($cur=null) {
00062         mysql_free_result($cur ? $cur : $this->cursor);
00063     }
00064 
00065     public function multiQuery ($sql) {
00066         $this->queries = explode (';', $sql);
00067         $this->qcursor = 0;
00068         return count($this->queries);
00069     }
00070 
00071     public function storeResult () {
00072         if (!empty($this->queries[$this->qcursor])) return $this->query ($this->queries[$this->qcursor]);
00073         return null;
00074     }
00075 
00076     public function nextResult () {
00077         $this->qcursor++;
00078         return isset($this->queries[$this->qcursor]);
00079     }
00080 
00081 }

Generated on Wed May 14 13:01:56 2008 for ALIRO by  doxygen 1.5.5