User . ":" . $this->Password . "@" . $this->Host . "/" . $this->Database; $this->dbhan =& MDB2::factory($dsn); if (PEAR::isError($this->dbhan)) { die("Construct: " . $this->dbhan->getMessage()); } $this->dbhan->setOption('result_buffering', True); if (!isset($this->Auto_Free)) $this->Auto_Free = False; if (!isset($this->Debug)) $this->Debug = False; if (!isset($this->type)) $this->type = $type; $this->Row = 0; $this->row_count = 0; } function query($query) { if ($this->Debug) echo $query; $aqcmd = preg_split("/\s+/", strtolower(trim($query)), 2); $qcmd = $aqcmd[0]; switch ($qcmd) { case "insert": case "delete": case "update": $this->row_count =& $this->dbhan->exec($query); if (PEAR::isError($this->row_count)) { echo $query."
"; die ("Exec: " . $this->row_count->getMessage()); } break; default: $this->qresult =& $this->dbhan->query($query); if (PEAR::isError($this->qresult)) { echo $query."
"; die("Query: " . $this->qresult->getMessage()); } $this->row_count = $this->qresult->numRows(); } } function next_record() { $this->Record = $this->qresult->fetchRow(MDB2_FETCHMODE_ASSOC); $this->Row = $this->qresult->rowCount(); if ($this->Record == NULL) { if ($this->Auto_Free) $this->qresult->free(); return False; } else return True; } function all_records() { $cur_row = $this->Row; $this->qresult->seek(0); $this->Record = $this->qresult->fetchAll(MDB2_FETCHMODE_ASSOC); if (PEAR::isError($this->qresult)) { die("All_records: " . $this->qresult->getMessage()); } if ($this->qresult->rowCount() > 0) { $this->qresult->seek($cur_row); return $this->Record; } else return False; } function num_rows() { return $this->row_count; } function affected_rows() { return $this->row_count; } function nf() { return $this->row_count; } function np() { echo $this->row_count; } function num_fields() { return count($this->Record); } function f($colname) { return $this->Record[$colname]; } function p($colname) { echo $this->Record[$colname]; } function seek($pos) { $this->qresult->seek($pos); if (PEAR::isError($this->qresult)) { die("Seek: " . $this->qresult->getMessage()); } $this->Record = $this->qresult->fetchRow(MDB2_FETCHMODE_ASSOC); $this->Row = $this->qresult->rowCount(); $this->qresult->seek($pos); } function get_db() { return $dbhan; } } ?>