/** * Create a prepared statement that can be executed later. * * @param Dataset $dataset RDF Dataset * @param Query $query Parsed SPARQL query * * @return SparqlEngineDb_PreparedStatement Prepared statment that can * be execute()d later. */ public function prepare(Dataset $dataset, Query $query) { require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/PreparedStatement.php'; require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/Preparator.php'; $this->query = $query; $this->dataset = $dataset; $this->sg = new SparqlEngineDb_SqlGenerator($this->query, $this->dbConn, $this->arModelIds); $this->rc = new SparqlEngineDb_ResultConverter($this->query, $this->sg, $this); $this->ts = new SparqlEngineDb_TypeSorter($this->query, $this->dbConn); $this->pr = new SparqlEngineDb_Preparator($this->query, $this->dbConn); $this->arPrepared = $this->sg->createSql(); $this->ts->setData($this->sg); if ($this->ts->willBeDataDependent()) { $this->bRealPrepared = false; } else { $this->bRealPrepared = true; list($strSelect, $strFrom, $strWhere) = $this->arPrepared; $this->arPreparedQueries = $this->ts->getOrderifiedSqls($strSelect, $strFrom, $strWhere); $this->arDbStatements = $this->pr->prepareInDb($this->arPreparedQueries, $this->sg->getPlaceholders()); } return new SparqlEngineDb_PreparedStatement($this); }