Hi Sören,

I have installed the 1M BSBM data into a 64bit Windows Virtuoso 6.2 instance 
and querying via the Conductor , isql or ODBC Directly I get the same 159 
distinct rows returned:

$ /opt/virtuoso/bin/isql opluswinbuild:1111
Connected to OpenLink Virtuoso
Driver: 06.02.3128 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.

SQL> sparql SELECT DISTINCT ?o FROM <http://mytest>  WHERE {?s a ?o};
o
VARCHAR
_______________________________________________________________________________

http://xmlns.com/foaf/0.1/Person
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType1
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/ProductType
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType2
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType3
.
.
.
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType150
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType151
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/ProductFeature
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Producer
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Product
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Vendor
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Offer
http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Review

159 Rows. -- 958 msec.
SQL>

So the problem is not in the ODBC layer, but rather in the PHP ODBC interface 
it seems. 

In fact the problem seems to be with the "odbc_fetch_array()" function which is 
fetching an array of results , as If I use the following sample PHP code which 
selects one row at a time the correct 159 distinct rows are returned:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
  <title>PHP ODBC test</title>
  <style type="text/css">
body { padding: 1em; }
pre  { padding: 0.3em; background-color: #e0e0e0; border: solid 1px silver }
  </style>
</head>

<body>
  <h1>Test PHP / ODBC / Virtuoso connection</h1>
  <hr />

<pre>


<?php
  ini_set("odbc.default_cursortype", "0");

  $con=odbc_connect("Local Virtuoso", "dba", "dba");
  if($con) {
    printf("<p>Connected [%s].\n</p>\n", $con);

    $query="sparql SELECT DISTINCT ?o FROM <http://mytest>  WHERE {?s a ?o}";

    print "Executing query [$query]<br />\n";
    $rs = odbc_exec($con, $query);

    $err=odbc_errormsg($con);
    print "Current error state: [$err]<br />\n";

    print "Results:<br />\n";
    odbc_result_all($rs, "border=2");
    odbc_close($con);
  } else {
    print "<p>Failed to connect!</p>\n";
  }
?>

?>   

  <hr />
</body>
</html>

Lifted from http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtuosoPHP 
documentation.

I shall look into why the "odbc_fetch_array()" function is problematic in the 
morning ...

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support
Twitter: http://twitter.com/OpenLink

On 21 Nov 2010, at 22:09, Sören Auer wrote:

> Hi all,
> 
> I have a problem with a SPARQL query using the DISTINCT feature.
> I installed the commercial Virtuoso 6.2 distribution for Windows.
> In order to run some experiments, I loaded the 1M BSBM data [1].
> 
> When I run the following query in conductor I get the correct results:
> 
> SELECT DISTINCT ?o FROM <http://mytest.com> WHERE {?s a ?o}
> 
> However, when running the same query from a hosted PHP script, the 
> results are not distinct anymore and I also get only a small subset:
> 
> <?php
> $c=odbc_connect("Local Virtuoso",'dba','dba');
> $r=odbc_exec($c,'sparql SELECT DISTINCT ?o FROM <http://mytest.com> 
> WHERE {?s a ?o}');
> while($row=odbc_fetch_array($r))
>       print_r($row);
> ?>
> 
> What's the problem? How can it be that I get different results from 
> conductor and when submitting a query via ODBC? Or am I doing something 
> wrong?
> 
> Best,
> 
> Sören
> 
> [1] 
> http://www4.wiwiss.fu-berlin.de/bizer/BerlinSPARQLBenchmark/datasets/qualification.ttl.gz
> 
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Virtuoso-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users


Reply via email to