topical media & game development
server-php-xml-class-rdql-db-class-rdql-db.php / php
<?php
// # # # # # # # # # # # # # # # # # # # ###
// Title : RDQL_db (class_rdql_db.php)
// Version : 1.0
// Author : Luis Argerich (lrargerich@yahoo.com)
// Last modification date : 07-03-2002
// Description : This class implements the RDQL language
// for RDF documents stored in a MySQL database
// methds to store and rertieve RDF documents
// from a MySQL database are provided as well.
// # # # # # # # # # # # # # # # # # # # ###
// History:
// 07-03-2002 : First release of this class
// # # # # # # # # # # # # # # # # # # # ###
// To-Dos:
// # # # # # # # # # # # # # # # # # # # ###
// How to use it: First read the README, then check the documentation in
// class_rdql_db.html and the example in example.php
// # # # # # # # # # # # # # # # # # # # ###
include_once("class_rdql.php");
include_once("class_rdf_parser.php");
class RDQL_query_db {
// Queries documents passed as urls or filenames (use urls or filenames in the FROM part of the RDQL query)
function rdql_query_db(iterator = new RDF_rdqldb_iterator();
iterator);
q->parse_query(res;
}
} // end of class
// This class provides
class RDQL_db {
var warning_mode=0;
var key;
var this->error;
}
// Sets warning mode, if true all the errors produce a PHP warning
function set_warning_mode(this->warning_mode=msg)
{
msg;
if(this->error,E_USER_WARNING);
}
return false;
}
function remove_rdf_document(query = "delete from rdf_documents where docKey='query);
key'";
mysql_query(url,this->key = this->statements = 0;
key'";
query);
result);
res[0];
if(this->_throw_error("The collection key");
return false;
}
url,"r");
if(!this->_throw_error("The url or filename rdf_parser=new Rdf_parser();
rdf_parser->rdf_set_statement_handler( "_class_rdf_store_statement_handler" );
this );
date = date("U");
date,'result = mysql_query(result) {
query);
return false;
}
while(!feof(buf = fread(size+=strlen(bufd=addslashes(rdf_parser->rdf_parse(data), feof(this->_throw_error("XML error while parsing the document in line:".xml_get_current_line_number(query = "update rdf_documents set data = concat(data,'key'";
mysql_query(query="update rdf_documents set size='key'";
mysql_query(query = "update rdf_documents set statements='key'";
mysql_query(rdf_parser->rdf_parser_free();
return true;
}
function get_rdf_document(query = "select data from rdf_documents where docKey='result = mysql_query(result)==0) {
key document was found in collection res = mysql_fetch_array(res["data"];
}
} //end of class
/* This function is used by the class as a hander to the RDF_parser */
function _class_rdf_store_statement_handler(&subject_type,predicate,object_type,xml_lang) {
//Just store the information in a database row.
user_data->key;
user_data->collection;
key',subject','object_type,'ordinal)";
mysql_query(user_data->statements++;
}
class RDF_rdqldb_iterator extends RDF_iterator {
var collection;
function init(id) {
id;
}
function get_tuple() {
}
function find_tuples(subject,object) {
sources)==1 && ((trim(sources[0])=='<*>') )) {
query="select docKey from rdf_documents";
query);
while(result)) {
res["docKey"].'>';
}
}
// And now we have the sources
foreach(source) {
preg_match("/\<([^>]*)\>/",reqs);
reqs[1];
source'";
//print(sql_result=mysql_query(sql_result) {
die(mysql_error());
}
while(sql_result)) {
this->tuple_match(res["subject"]) &&
predicate,this->tuple_match(res["object"])) {
subject{0}=='?') {
subject]=predicate{0}=='?') {
predicate]=object{0}=='?') {
object]=result)>0) {
result;
}
}
}
}
return
(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.