topical media & game development

talk show tell print

server-php-xml-class-rdql-db-class-rdql-db.htm / htm



  <html>
  <head>
  <title>RDQL DB(class_rdql_db.php)</title>
  <link rel="stylesheet" href="main.css" type="text/css">
  </head>
  
  <body>
  
  <div align="center">
  <table border="0" width="80%" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#aaaaee" class="text" align="center"><a href="http://phpxmlclasses.sourceforge.net/">PHP XML Classes</a></td>
  </tr>
  </table>
  <table border="0" width="80%" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#aaaaee" class="textblbl" align="center">RDQL DB (class_rdql_db.php)</td>
  </tr>
  </table>
  <br/>
  <table border="0" width="80%">
  <tr>
    <td bgcolor="#eeeeff" class="text">Description: This class implements the <a href="rdql.html">RDQL</a> language to query RDF documents stored in a
    MySQL database. The RDF documents can be stored, retrieved and deleted from the database using the RDQL_db class, documents
    can be stored from file paths or URLs<br/><br/>
    Since RDF documents are parsed and stored in the database as RDF statements the RDQL implementation is fast since the
    database is scanned for RDF statements without the need to parse the document (parse once, query many).<br/><br/>
    There're two classes in this package to be used: RDQL_db implements methods to store,delete and retrieve documents
    while RDQL_query_db implements the RDQL language engine.
    </td>
  </tr>
  </table>
  <br/>
  <table border="0" bgcolor="ddddff" width="80%">
  <tr>
    <td valign="top" class="text" width="50%"><b>NEWS:</b>
    <ul>
      <li> 2002-07-03 First version of this class released.
    </ul>
    </td>
    <td valign="top" width="50%" class="text">
       This class code as well as the documentation are hosted at <a href="http://www.sourceforge.net">SourceForge</a>
       please visit our <a href="http://phpxmlclasses.sourceforge.net/">SourceForge page</a> for releases, documentation, bug-tracking, support
       forums and mailing lists.
    </td>
  </tr>
  </table>
  <br/>
  <table border="0" width="80%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="textbl" bgcolor="aaaaee" width="50%">Resources</td>
    <td class="textbl" bgcolor="aaaaee" width="50%">Requirements</td>
  </tr>
  </table>
  <table border="1" width="80%" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top" bgcolor="eeeeff" class="text" width="50%">
    <ul>
      <li><a class="textbl" href="http://www.sourceforge.net/projects/phpxmlclasses">Downloads</a>
      <li><a class="textbl" href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpxmlclasses/rdql_db/">Browse CVS</a>
      <li><a class="textbl" href="http://sourceforge.net/tracker/?atid=470965&group_id=53613&func=browse">Report Bugs</a>
    </ul>
    </td>
    <td valign="top" bgcolor="eeeeff" class="text" width="50%">
    <ul>
      <li>PHP 4.0.5+
    </ul>
    </td>
  </tr>
  </table>
  <br/>
  
  <table border="0" width="80%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="textbl" bgcolor="aaaaee" width="50%">Features</td>
    <td class="textbl" bgcolor="aaaaee" width="50%">To-dos</td>
  </tr>
  </table>
  <table border="1" width="80%" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top" bgcolor="eeeeff" class="text" width="50%">
    <ul>
      <li>Documents are parse before being stored in the database
      <li>You can query multiple documents or use * to query all documents in the database
    </ul>
    </td>
    <td valign="top" bgcolor="ddddff" class="text" width="50%">
    <ul>
      <li>If you have a suggestion please let me know it
    </ul>
    </td>
    
  </tr>
  </table>
  <br/>
  <table border="0" bgcolor="ddddff" width="80%">
  <tr>
  <!--
    <td valign="top" class="text" width="50%"><b>To-do/future releases:</b>
    <ul>
      <li>Class 
      <li>Class 
      <li>Class 
    </ul>
    </td> -->
    <td valign="top" width="100%" class="text">
       Contact: <a href="mailto:lrargerich@yahoo.com">;Luis Argerich</a>
    </td>
  </tr>
  </table>
  <br/>
  <table border="0" bgcolor="ddddff" width="80%">
  <tr>
  <!--
    <td valign="top" class="text" width="50%"><b>To-do/future releases:</b>
    <ul>
      <li>Class 
      <li>Class 
      <li>Class 
    </ul>
    </td> -->
    <td valign="top" width="100%" class="text">
    Detailed description and usage:<br/>
  <b>Using the class:</b><br/><br/>
  First of all you need to create a mysql database and import the RDQL_db tables structure
  to that database, if your database is named foo you can do it using:
  <pre>
  mysql foo < rdql_db.sql
  </pre>
  This will create all the tables needed by the RDQL_db and RDQL_query_db classes. Now
  in your script you have to connect to MySQL and selet the database where the tables
  were created:
  <pre>
  mysql_connect("localhost","root","");
  mysql_select_db("foo");
  </pre>
  If you created a MySQL user with permisions only to the foo database or the RDQL_db tables
  just replace root,"" with the user name and password.<br/><br/>
  <b>Storing, retrieving and deleting RDF documents</b><br/><br/>
  The RDQL_db class let's you store, retrieve and delete documents from the databse, examples:
  <pre>
  db = new RDQL_db();
  db->store_rdf_document("http://example.com/foo.rdf","foo"); //Store from URL using key=foo
  db->store_rdf_document("people.rdf","people"); //Store from the local file system
  db->remove_rdf_document("foo"); // Eliminate a document
  doc = db->get_rdf_document("people"); // Retrieve a document
  </pre>
  <b>Querying the database</b><br/><br/>
  Once you have the RDF documents stored you can query the database using the RDQL_query_db class,
  in the from section of the query you have to use the keys as you entered them to store the
  documents, you can query multiple documents and you can even use * to query all the documents
  in the database. Example:
  <pre>
  SELECT ?x,?y,?z
  FROM &lt;people&gt;,&lt;salaries&gt;
  WHERE (?x,&lt;dt:salary&gt;,?y),(?x,&lt;dt:age&gt;,?z)
  AND ?y>200
  USING dt for &lt;http://foo.org#>, rdf for &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  >
  This will query documents stored with keys "salaries" and "people". You can check the file 
  <example.php> for some queries, documents and operations. You can also check the <a href="rdql.tml">RDQL
  tutorial</a> for a description of what can you do with this RDQL implementation.
  <br/>
  
  <h3>Documentation</h3>
  </div>
  <h2>Classes</h2>
  <ul>
    <li><a href="#class36">RDQL_query_db</a></li>
    <li><a href="#class37">RDQL_db</a></li>
    <li><a href="#class38">RDF_rdqldb_iterator</a></li>
  </ul>
  
  <a name="class36"></a>
  <h3>RDQL_query_db</h3>
  Extends: None
Description: This class implements the RDQL language for RDF documents stored in a MySQL database using the RDQL_db class.
<br> <!-- METHOD SUMMARY --> <A NAME="pDomNode_method_summary"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;array</CODE></FONT></TD> <TD><CODE><B><A HREF="#class36method1">rdql_query_db</A></B>(string query)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries documents in the database</TD> </TR> <!-- A ROW --> </TABLE> &nbsp; <P> <!-- METHOD SUMMARY --> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <!-- method --> <A NAME="class36method1"><!-- --></A> <H3>rdql_query_db</H3> <PRE> array <B>rdql_query_db</B>(string query)</PRE> <DL> <DD>This method is used to query RDF documents stored in a MySQL database, the documents are indicated in the FROM part of the RDQL query using the keys that you used when the documents were stored in the database using RDQL_db class.<DD>&nbsp; <DL> <DT><B>Parameters:</B><DD> query - The RDQL query, in the from part you should use * or a list of comma sepparated document keys enclosed by angle brackets. Example: &lt;foo&gt;,&lt;people&gt;<br><DT><B>Returns:</B><DD>An array of result rows. Each row is an asociative array mapping RDQL variables to their values.<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- ============ METHOD DETAIL ========== --> <a name="class37"></a> <h3>RDQL_db</h3> Extends: None
Description: A class to store, retrieve and delete RDF documents from Mysql. Once parsed and stored the documents can be queried using the RDQL_query_db class.
<br> <!-- METHOD SUMMARY --> <A NAME="pDomNode_method_summary"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;string</CODE></FONT></TD> <TD><CODE><B><A HREF="#class37method1">get_error</A></B>(string query)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns last error message</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="#class37method2">remove_rdf_document</A></B>(string key)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Removes an RDF document from the database</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="#class37method3">store_rdf_document</A></B>(string url, string key)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stores an RDF document in the database</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;string</CODE></FONT></TD> <TD><CODE><B><A HREF="#class37method4">get_rdf_document</A></B>(string key)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Retrieves a document from the database</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="#class37method5">set_warning_mode</A></B>(boolean mode)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the warning mode for class errors </TR> <!-- A ROW --> </TABLE> &nbsp; <P> <!-- METHOD SUMMARY --> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <!-- method --> <A NAME="class37method1"><!-- --></A> <H3>get_error</H3> <PRE> string <B>get_error</B>()</PRE> <DL> <DD>If a mehtod of this class fails then an error message is set in the object and you can ask for it using this method.<DD>&nbsp; <DL> <DT><B>Parameters:</B><DD> <DT><B>Returns:</B><DD>The last error message produced.<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class37method2"><!-- --></A> <H3>remove_rdf_document</H3> <PRE> void <B>remove_rdf_document</B>(string key)</PRE> <DL> <DD>Removes an RDF document from the database, you have to indicate the document Key to remove it.<DD>&nbsp; <DL> <DT><B>Parameters:</B><DD> key - The key of the document to be deleted (the key you used to store the document)<br><DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class37method3"><!-- --></A> <H3>store_rdf_document</H3> <PRE> boolean <B>store_rdf_document</B>(string url, string key)</PRE> <DL> <DD>This method is used to parse an RDF document from a path or URL and store it in the database with a given key. The key is what you use to retrieve, query or delete the document after it was stored.<DD>&nbsp; <DL> <DT><B>Parameters:</B><DD> url - URL or file-path of the RDF document to be stored<br>key - Key for the document in the database<br><DT><B>Returns:</B><DD>True if the document was stored, false if not<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class37method4"><!-- --></A> <H3>get_rdf_document</H3> <PRE> string <B>get_rdf_document</B>(string key)</PRE> <DL> <DD>This method is used to retrieve an RDF document from the database using its key to access the document.<DD>&nbsp; <DL> <DT><B>Parameters:</B><DD> key - The key of the document to be retrieved<br><DT><B>Returns:</B><DD>The document as a PHP string<DT><B>Throws:</B><DD><CODE>IF there's an error the method returns false and the error message can be accessed using get_error()</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class37method5"><!-- --></A> <H3>set_warning_mode</H3> <PRE> void <B>set_warning_mode</B>(boolean mode)</PRE> <DL> <DD>Sets the warning mode for class errors. When the warning mode is true then if theres an error in a class method a PHP warning is issued. If the warning mode is false then no warnings are reported and you can access the error message using get_error.<DD>&nbsp; <DL> <DT><B>Parameters:</B><DD> mode - True to set warning mode to true false to unset it<br><DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- ============ METHOD DETAIL ========== --> <a name="class38"></a> <h3>RDF_rdqldb_iterator</h3> Extends: RDF_iterator
Description: This iterator can be used to implement the RDQL generic engine for RDF documents stored in a mysql database using the RDQL_db class.
<br> <!-- METHOD SUMMARY --> <A NAME="pDomNode_method_summary"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <tr><td><p align=center>This class doesn´t have any method</p></td></tr></TABLE> &nbsp; <P> <!-- METHOD SUMMARY --> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <tr><td><p align=center>This class doesn´t have any method</p></td></tr><!-- ============ METHOD DETAIL ========== --> </td> </tr> </table> </body> </html>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.