ColumnNames = array(); $this->AssociativeArray = array(); $this->IntegerArray = array(); } public function GetRow($mode=DatabaseResult::ASSOCIATIVE) { if ($this->Position >= $this->NumRows) return false; $this->Seek($this->Position + 1); if ($mode == DatabaseResult::INTEGER) return $this->IntegerArray[$this->Position-1]; elseif ($mode == DatabaseResult::ASSOCIATIVE) return $this->AssociativeArray[$this->Position-1]; } public function Seek($offset) { $this->Position = $offset; } } class MySQLdb extends DatabaseCommon implements DatabaseInterface { public $Error; public $AffectedRows; private $Statements; private $Result; public function __construct($hostname, $username, $password, $database) { $this->Statements = array(); $this->Connect($hostname, $username, $password, $database); } public function Connect($hostname, $username, $password, $database) { $this->Link = @mysql_connect($hostname, $username, $password); if (!$this->Link) $this->Error(DatabaseCommon::DB_CONNECT_ERROR, 'Could not connect to MySQL server.'); $selected = @mysql_select_db($database, $this->Link); if (!$selected) $this->Error(DatabaseCommon::DB_CONNECT_ERROR, "Could not select database: $database. Error: " . mysql_error($this->Link)); $this->Result = NULL; } public function AutoCommit($bool) { } public function Commit() { } public function RollBack() { } public function Prepare($name, $query) { } public function Execute($name, $result_type=DatabaseCommon::DB_BUFFERED_RESULT) { } public function Query($query, $result_type=DatabaseCommon::DB_BUFFERED_RESULT) { $this->Result = @mysql_query($query, $this->Link); if (!$this->Result) $this->Error(DatabaseCommon::DB_QUERY_ERROR, "Query: '". $query . "' failed. Error: " . mysql_error()); if (strtolower($query[0]) != 's') { $this->AffectedRows = @mysql_affected_rows($this->Link); @mysql_free_result($this->Result); $this->Result = NULL; } } public function GetRow($query=NULL) { if ($query != NULL) $this->Query($query); $result = $this->GetResult(); return $result->GetRow(); } public function GetResult() { if ($this->Result == NULL) return false; $result = new MySQLDatabaseResult(); $result->NumCols = @mysql_num_fields($this->Result); $result->NumRows = @mysql_num_rows($this->Result); $iarr = array(); while ($iarr = @mysql_fetch_array($this->Result, MYSQL_NUM)) $result->IntegerArray[] = $iarr; @mysql_data_seek($this->Result, 0); $aarr = array(); while ($aarr = @mysql_fetch_array($this->Result, MYSQL_ASSOC)) $result->AssociativeArray[] = $aarr; for ($i = 0; $i < $result->NumCols; $i++) $result->ColumnNames[] = @mysql_field_name($this->Result, $i); @mysql_free_result($this->Result); $this->Result = NULL; return $result; } } ?>