queryLanguage) { case 'MMBQ': // simple parsing of crappy format, will add support for VSQI and RDQL query languages $sql = "SELECT "; $sql .= join(",", $this->res_fields); $sql .= " FROM " . $this->mdl_table; $conditions = split("\n", $queryStatement); $sql .= " WHERE 1 "; while ($cond = array_shift($conditions)) { $condpair = split("=", $cond, 2); $sql .= " AND " . urldecode($condpair[0]) . " LIKE '%" . urldecode($condpair[1]) . "%'\n"; } //$res = mysql_query($sql, $this->mysql_link); $res_set = array(); while ($row = mysql_fetch_assoc($res)) array_push($res_set, $row); return $res_set; break; case 'VSQI': $sql = "SELECT "; //$sql .= join(",", $this->res_fields); $sql .= "*"; $sql .= " FROM ".$wpdb->posts; $vsqi = simplexml_load_string($queryStatement); $sql .= " WHERE 1 "; foreach ($vsqi as $key => $value) $sql .= " AND " . $key . " LIKE '%" . $value . "%'\n"; if ( $ret_query ) return $sql; //$res = mysql_query($sql, $this->mysql_link); $res = $wpdb->get_results("select wp_posts.* from wp_posts left join wp_ext_soap on wp_posts.ID = wp_ext_soap.ID WHERE wp_ext_soap.ID IS NULL;", ARRAY_A); return $res; break; default: break; } } private function results_list($start = 0) { $formatter; switch ($this->resultsFormat) { default: case 'MMBR': $formatter = new MMBR_Formatter(); break; } for ($i = $start; $i < $this->resultsSetSize; $i++) { if (!$this->results[$i]) break; $resrow = $this->results[$i]; $formatter->add($resrow); } return $formatter->dump(); } function setQueryLanguage($targetSessionID, $queryLanguageID) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); if (!$this->validateQueryLanguage($queryLanguageID)) throw new QueryLanguageNotSupportedException("Query language \"" . $queryLanguageID . "\" not supported"); $this->queryLanguage = $queryLanguageID; return ""; } function setResultsFormat($targetSessionID, $resultsFormat) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); if (!$this->validateResultsFormat($resultsFormat)) throw new ResultsFormatNotSupportedExceptions("Results format \"" . $resultsFormat . "\" not supported"); $this->resultsFormat = $resultsFormat; } function setMaxQueryResults($targetSessionID, $maxQueryResults) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); if (!is_int($maxQueryResults)) throw new InvalidMaxQueryResultsException("Invalid number supplied: " . $maxQueryResults); $this->maxQueryResults = $maxQueryResults; } // ATT. this method has to do with asynchronous querying, which won't be implemented currently function setMaxDuration($targetSessionID, $maxDuration) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); if (!is_int($maxDuration)) throw new InvalidMaxDurationException("Invalid number supplied: " . $maxDuration); $this->maxDuration = $maxDuration; } function setResultsSetSize($targetSessionID, $resultsSetSize) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); if (!is_int($resultsSetSize)) throw new InvalidResultsSetSizeExceptionion("Invalid number supplied: " . $resultsSetSize); $this->resultsSetSize = $resultsSetSize; } function synchronousQuery($targetSessionID, $queryStatement) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); //return $this->process_query($queryStatement, 1); $this->results = $this->process_query($queryStatement); $this->totalResultsCount = count($this->results); // we need to save this value /* if (!$this->results) throw new InvalidQueryStatementException("Query statement does not comply with query language syntax (query language:" . $this->queryLanguage . ")"); */ //return var_dump_ret($this->results); return $this->results_list(); } function getTotalResultsCount($targetSessionID) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); return $this->totalResultsCount; } function getAdditionalQueryResults($targetSessionID, $startResult) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); if (!$this->results) throw new NoQuerySubmittedException(); if (!is_int($startResult) || $startResult > $this->totalResultsCount) throw new InvalidResultsSetSizeExceptionion("Invalid number supplied: " . $startResult); return $this->results_list($startResult); } function asynchronousQuery($targetSessionID, $queryStatement, $queryID) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); throw new QueryModeNotSupportedException("asynchronous queries are not supported at this time"); } function setSourceLocation($targetSessionID, $sourceLocation) { throw new QueryModeNotSupportedException("asynchronous queries are not supported at this time"); } function getResourceDescription($targetSessionID, $resourceID) { if (!$this->validateSession($targetSessionID)) throw new NoSuchSessionException("Invalid session ID supplied: " . $targetSessionID); throw new NoSuchResourceException("ResourceID's have no origin in standard outside of this function -- implementation impossible at this time"); } } ?>