 <?php 
 
	include_once("./ARC2/arc/ARC2.php");
	
	error_reporting(0); // disable error messages
	// see http://arc.semsol.org/docs for document of ARC2
			
	$config = array(
	  /* db */
	  'db_name' => 'arc2',
	  'db_user' => 'arc2',
	  'db_pwd' => 'arc2',
	  /* store */
	  'store_name' => 'arc_tests',
	  /* stop after 100 errors */
	  'max_errors' => 100,
	);
	$store = ARC2::getStore($config);
	if ($store)
	{
		echo "Connected to ARC2 database<br/>\n";
	}
	if (!$store->isSetUp()) {	  
	  $store->setUp();
	}
	
	$store->reset();

	//$store->query('LOAD <http://www.ivan-herman.net/foaf.rdf>');
    $store->query('LOAD <http://www.csail.mit.edu/~lkagal/foaf>');

	/* list names */
	$q = '
	  PREFIX foaf: <http://xmlns.com/foaf/0.1/> .
	  SELECT DISTINCT ?person ?name WHERE {
		<http://people.csail.mit.edu/lkagal/foaf#me> foaf:knows ?person .
		OPTIONAL {?person	foaf:name ?name }
	  }
	';
	//echo "Parse only the first 20";
	
	echo "<table>";
	if ($rows = $store->query($q, 'rows')) {
		$i = 0;
		foreach ($rows as $row) {
			$i = $i + 1;
			if ( $i > 100 ) break; // only the first 100
			$foafURL = $row['person'];		
			echo '<li>' . $row['name'] . '<br/>' . $foafURL . "</li>\n";	

			$store->query('LOAD <' . $foafURL . '>');			
		}
	}
		
 ?> 
 
