last_error="database creation is not supported"; return(0); } Function DropDatabase($database) { $this->last_error="database dropping is not supported"; return(0); } Function AlterTable($name,$changes,$check) { $this->last_error="database alteraion is not supported"; return(0); } Function Query($query) { $this->last_error="database queries are not implemented"; return(0); } Function PrepareQuery($query) { $positions=array(); for($position=-1;GetType($position=strpos($query,"?",$position+1))=="integer";) $positions[]=$position; $this->prepared_queries[]=array( "Query"=>$query, "Positions"=>$positions, "Values"=>array() ); return(count($this->prepared_queries)); } Function ValidatePreparedQuery($prepared_query) { if($prepared_query<1 || $prepared_query>count($this->prepared_queries)) { $this->last_error="invalid prepared query"; return(0); } if(GetType($this->prepared_queries[$prepared_query-1])!="array") { $this->last_error="prepared query was already freed"; return(0); } return(1); } Function FreePreparedQuery($prepared_query) { if(!$this->ValidatePreparedQuery($prepared_query)) return(0); $this->prepared_queries[$prepared_query-1]=""; return(1); } Function ExecuteQuery($prepared_query) { if(!$this->ValidatePreparedQuery($prepared_query)) return(0); $index=$prepared_query-1; for($query="",$last_position=$position=0;$positionprepared_queries[$index]["Positions"]);$position++) { if(!IsSet($this->prepared_queries[$index]["Values"][$position])) { $this->last_error="it was not defined query argument ".($position+1); return(0); } $current_position=$this->prepared_queries[$index]["Positions"][$position]; $query.=substr($this->prepared_queries[$index]["Query"],$last_position,$current_position-$last_position).$this->prepared_queries[$index]["Values"][$position]; $last_position=$current_position+1; } $query.=substr($this->prepared_queries[$index]["Query"],$last_position); return($this->Query($query)); } Function QuerySet($prepared_query,$parameter,$type,$value) { if(!$this->ValidatePreparedQuery($prepared_query)) return(0); $index=$prepared_query-1; if($parameter<1 || $parameter>count($this->prepared_queries[$index]["Positions"])) { $this->last_error="it was not specified a valid argument number"; return(0); } $this->prepared_queries[$index]["Values"][$parameter-1]=$value; return(1); } Function QuerySetNull($prepared_query,$parameter,$type) { return($this->QuerySet($prepared_query,$parameter,$type,"NULL")); } Function QuerySetText($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"text",$this->GetTextFieldValue($value))); } Function QuerySetInteger($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"integer",$this->GetIntegerFieldValue($value))); } Function QuerySetBoolean($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"boolean",$this->GetBooleanFieldValue($value))); } Function QuerySetDate($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"date",$this->GetDateFieldValue($value))); } Function QuerySetTimestamp($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"timestamp",$this->GetTimestampFieldValue($value))); } Function QuerySetTime($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"time",$this->GetTimeFieldValue($value))); } Function QuerySetFloat($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"float",$this->GetFloatFieldValue($value))); } Function QuerySetDecimal($prepared_query,$parameter,$value) { return($this->QuerySet($prepared_query,$parameter,"decimal",$this->GetDecimalFieldValue($value))); } Function AffectedRows(&$affected_rows) { if($this->affected_rows==-1) { $this->last_error="there was no previous valid query to determine the number of affected rows"; return(0); } $affected_rows=$this->affected_rows; return(1); } Function FetchResult($result,$row,$field) { $this->warning="method not implemented"; return(""); } Function ResultIsNull($result,$row,$field) { $value=$this->FetchResult($result,$row,$field); return(!IsSet($value)); } Function FetchDateResult($result,$row,$field) { return($this->ResultIsNull($result,$row,$field) ? "NULL" : $this->FetchResult($result,$row,$field)); } Function FetchTimestampResult($result,$row,$field) { return($this->ResultIsNull($result,$row,$field) ? "NULL" : $this->FetchResult($result,$row,$field)); } Function FetchTimeResult($result,$row,$field) { return($this->ResultIsNull($result,$row,$field) ? "NULL" : $this->FetchResult($result,$row,$field)); } Function FetchBooleanResult($result,$row,$field) { return($this->ResultIsNull($result,$row,$field) ? "NULL" : !strcmp($this->FetchResult($result,$row,$field),"Y")); } Function FetchFloatResult($result,$row,$field) { return($this->ResultIsNull($result,$row,$field) ? "NULL" : $this->FetchResult($result,$row,$field)); } Function FetchDecimalResult($result,$row,$field) { return($this->ResultIsNull($result,$row,$field) ? "NULL" : $this->FetchResult($result,$row,$field)); } Function NumberOfRows($result) { $this->warning="method not implemented"; return(0); } Function FreeResult($result) { $this->warning="method not implemented"; return(0); } Function Error() { return($this->last_error); } Function GetIntegerFieldTypeDeclaration($name,&$field) { if(IsSet($field["unsigned"])) $warning="unsigned integer field \"$name\" is being declared as signed integer"; return("$name INT".(IsSet($field["default"]) ? " DEFAULT ".$field["default"] : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetTextFieldTypeDeclaration($name,&$field) { return((IsSet($field["length"]) ? "$name CHAR (".$field["length"].")" : "$name TEXT").(IsSet($field["default"]) ? " DEFAULT ".$this->GetTextFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetBooleanFieldTypeDeclaration($name,&$field) { return("$name CHAR (1)".(IsSet($field["default"]) ? " DEFAULT ".$this->GetBooleanFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetDateFieldTypeDeclaration($name,&$field) { return("$name CHAR (".strlen("YYYY-MM-DD").")".(IsSet($field["default"]) ? " DEFAULT ".$this->GetDateFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetTimestampFieldTypeDeclaration($name,&$field) { return("$name CHAR (".strlen("YYYY-MM-DD HH:MM:SS").")".(IsSet($field["default"]) ? " DEFAULT ".$this->GetTimestampFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetTimeFieldTypeDeclaration($name,&$field) { return("$name CHAR (".strlen("HH:MM:SS").")".(IsSet($field["default"]) ? " DEFAULT ".$this->GetTimeFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetFloatFieldTypeDeclaration($name,&$field) { return("$name TEXT ".(IsSet($field["default"]) ? " DEFAULT ".$this->GetFloatFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetDecimalTypeDeclaration($name,&$field) { return("$name TEXT ".(IsSet($field["default"]) ? " DEFAULT ".$this->GetDecimalFieldValue($field["default"]) : "").(IsSet($field["notnull"]) ? " NOT NULL" : "")); } Function GetIntegerFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : "$value"); } Function GetTextFieldValue($value) { return("'$value'"); } Function GetBooleanFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : ($value ? "'Y'" : "'N'")); } Function GetDateFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : "'$value'"); } Function GetTimestampFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : "'$value'"); } Function GetTimeFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : "'$value'"); } Function GetFloatFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : "'$value'"); } Function GetDecimalFieldValue($value) { return(!strcmp($value,"NULL") ? "NULL" : "'$value'"); } Function Support($feature) { return(IsSet($this->supported[$feature])); } Function CreateSequence($name,$start) { $this->last_error="sequence creation is not supported"; return(0); } Function DropSequence($name) { $this->last_error="sequence dropping is not supported"; return(0); } Function GetSequenceNextValue($name,&$value) { $this->last_error="getting sequence next value is not supported"; return(0); } Function GetSequenceNextValue($name,&$value) { $this->last_error="getting sequence current value is not supported"; return(0); } Function AutoCommitTransaction() { $this->last_error="transactions are not supported"; return(0); } Function CommitTransaction() { $this->last_error="commiting transactions are not supported"; return(0); } Function RollbackTransaction() { $this->last_error="rolling back transactions are not supported"; return(0); } Function CreateIndex($table,$name,$definition) { $query="CREATE"; if(IsSet($definition["unique"])) $query.=" UNIQUE"; $query.=" INDEX $name ON $table ("; for($field=0,Reset($definition["FIELDS"]);$field0) $query.=","; $field_name=Key($definition["FIELDS"]); $query.=$field_name; if($this->Support("IndexSorting") && IsSet($definition["FIELDS"][$field_name]["sorting"])) { switch($definition["FIELDS"][$field_name]["sorting"]) { case "ascending": $query.=" ASC"; break; case "descending": $query.=" DESC"; break; } } } $query.=")"; return($this->Query($query)); } Function DropIndex($table,$name) { return($this->Query("DROP INDEX $name")); } Function Setup() { return(""); } }; ?>