miConexion = false; $this->lastQuery = ''; $this->miQueryRsrc = false; $this->miConexion = @mysql_connect($host, $user, $password); if ($this->miConexion) { if (!@mysql_select_db($database, $this->miConexion)) { $this->miConexion = false; } } return $this->miConexion; } function query($query) { $valor = false; if($this->miConexion) { $result = mysql_query($query, $this->miConexion); if ($result) { $this->lastQuery = strtoupper(substr($query, 0, strpos($query, ' '))); if($this->lastQuery == 'SELECT') { $this->miQueryRsrc = $result; $this->numOfRows = $this->getNumOfRows(); $this->currentRow = 0; } $valor = true; } } return $valor; } function getNumOfRows() { if($this->lastQuery == 'SELECT') { return mysql_num_rows($this->miQueryRsrc); } else { return mysql_affected_rows($this->miConexion); } } function getLastID() { return mysql_insert_id($this->miConexion); } function getNext() { $this->currentRow ++; $row = mysql_fetch_array($this->miQueryRsrc); return $row; } function getFirst() { mysql_data_seek($this->miQueryRsrc, 0); return $this->getNext(); } function getPrev() { if($this->currentRow > 0) { mysql_data_seek($this->miQueryRsrc, $this->currentRow); return $this->getNext(); } else { return false; } } function rewind() { mysql_data_seek($this->miQueryRsrc, 0); } function getLast() { mysql_data_seek($this->miQueryRsrc, $this->numOfRows - 1); return $this->getNext(); } function hasError() { return mysql_errno($this->miConexion); } function getError() { return array( 'text' => mysql_error($this->miConexion), 'num' => mysql_errno($this->miConexion)); } } ?>