arc2 not supporting sparql's OPTIONAL

39 views
Skip to first unread message

Bolle

unread,
Apr 24, 2012, 2:59:49 AM4/24/12
to arc...@googlegroups.com
Hello,
the following script is not working with arc2:
----

$q = '
    PREFIX ab: <http://example.com/ns/addressbook#>
    SELECT DISTINCT ?uri ?name ?email ?phone
    WHERE
    {
      ?uri ab:firstName ?name ;
     ab:email ?email .
    OPTIONAL
    {?uri ab:homeTel ?phone .}
    }';

$rs = $store->query($q);

  $rows = $rs['result']['rows'];

   foreach ($rows as $row) {
        $item1 = $row["name"];
        $item2 = $row["email"];   
        $item3 = $row["phone"]; 

        print "$item1 . $item2 . $item3 .\n";
        }
    }
---
not all cients in the database have a phone number, and when running directly this script with sparql
i get followiing result

client1 email1 phone1
client2 email2 phone2
client3    email3

and when running it on arc2 i get the error message: Undefined variable: item3
How can be solved this problem?
bk


Reply all
Reply to author
Forward
0 new messages