Virtuoso unicode issue - unicode

I got an issue with virtuoso on dbpedia server:
select distinct ?wt
where {
?wt rdfs:label "Concerto"#fr .
}
return http://dbpedia.org/resource/Concerto
select distinct ?wt
where {
?wt rdfs:label "Opéra"#fr .
}
return http://dbpedia.org/resource/Opéra
select distinct ?wt
where {
values ?ope {"Opéra"#fr}
?wt rdfs:label ?ope .
}
also return http://dbpedia.org/resource/Opéra, but
select distinct ?wt
where {
values ?ope {"Opéra"#fr "Concerto"#fr}
?wt rdfs:label ?ope .
}
only return http://dbpedia.org/resource/Concerto
In fact when I use values only non unicodes queries match if more than one value is given.

Related

blazegraph delete with query deletes entire namespace rather than just construct results

I am issuing a DELETE REST call to my local blazegraph:
http://localhost:9999/blazegraph/namespace/GraphInfo
with the body:
PREFIX rsabox:<http:\/\/ibm.com\/ResultSetABox#>
PREFIX rstbox:<http:\/\/ibm.com\/ResultSetTBox#>
CONSTRUCT {
?result ?pred ?obj .
?resultSet rstbox:hasResult ?result .
} WHERE {
SELECT ?result ?pred ?obj ?resultSet
WHERE {
?result rdf:type rstbox:queryResult .
?resultSet rstbox:hasResult ?result .
?resultSet rdf:type rstbox:resultSet .
?resultSet rstbox:setID ?setID .
FILTER (?setID = 1) .
?result ?pred ?obj .
FILTER (?pred NOT IN (
owl:topObjectProperty,
rstbox:topObjectProperty,
rstbox:hasRefInst,
rstbox:resultOf,
rdf:type
)
)
}
}
but the result is the entire namespace is deleted, rather than just the subject, predicate, object entries from the construct.
The response from blazegraph is:
"DELETED: GraphInfo"
Perhaps I'm not understanding the REST API correctly from here: https://wiki.blazegraph.com/wiki/index.php/REST_API#DELETE
Basically, I've created a set of results by posting text/turtle that I now want to remove from the graph (namespace). Should I POST (rather than DELETE) the same query, but rather than CONSTRUCT, use DELETE?
Also, do I need the filters or should I just delete everything that would include the inferred relationships (e.g., just using the ?result ?pred ?obj )
I turns out, I needed to POST with a body using update= with a DELETE query as follows:
update=PREFIX rsabox:<http://ibm.com/ResultSetABox#>
PREFIX rstbox:<http://ibm.com/ResultSetTBox#>
DELETE {
?result ?pred ?obj .
?resultSet rstbox:hasResult ?result .
} WHERE {
SELECT ?result ?pred ?obj ?resultSet
WHERE {
?result rdf:type rstbox:queryResult .
?resultSet rstbox:hasResult ?result .
?resultSet rdf:type rstbox:resultSet .
?resultSet rstbox:setID ?setID .
FILTER (?setID = 1) .
?result ?pred ?obj .
}
}
I'd been confused about their showing ?update on the URI and talking about issuing a query...

tell me why this is only returning 1 result

$sql="SELECT * FROM oc_category where parent_id = '253' "; // grab the category id from the parent id
$result=mysqli_query($con,$sql);
$Pid=mysqli_fetch_assoc($result);
$sql="SELECT * FROM oc_category_description where category_id = '$Pid[category_id]' "; // grab the category name from the category id
$result=mysqli_query($con,$sql);
$Cid=mysqli_fetch_assoc($result);
{
// show the results
echo '<a target="_top" href="index.php?route=product/products&product_id=' .
$Cid['category_id'] . '"><span class="cat">' . substr($Cid['category_id'], 0,
50),('') . '</span></a><br>' . '' . "\n";
}
I think you are better off doing a join - so that you only have one query. Your new query would be:
SELECT desc.*
FROM oc_category cat, oc_category_description desc
WHERE cat.parent_id = '253'
and cat.category_id = desc.category_id

Zend Framework Inner Join Query

I am not sure why Zend makes it difficult to write queries. I am from CodeIgniter background.
I want to write this query
SELECT tbllicenses.*, tblclients.email As clientemail FROM tbllicenses
INNER JOIN tblclients ON tblclients.id = tbllicenses.clientid
Do you know how can I write this query without using "table AS t" kind of assignments ?
Having table aliases is the standard way to write queries. so if you will go for zend join functions then aliases are required. Another way around is that you can pass the whole query to '$this->db->query("query....")'.
One way to do it could be:
class Application_Model_Soa_Service_LicenseService extends Zend_Db_Table_Abstract
{
public function getLicenses()
{
$statementString = " ";
$statementString .= " SELECT ";
$statementString .= " tbllicenses.*, ";
$statementString .= " tblclients.email As clientemail ";
$statementString .= " FROM tbllicenses ";
$statementString .= " INNER JOIN tblclients ON tblclients.id = tbllicenses.clientid ";
$statementQuery = $this->_db->prepare($statementString);
$statementQuery->execute();
$rowsetData = $statementQuery->fetchAll();
return $rowsetData;
}
}

Select query in zend framework 2.2 with multiple where clause and order by desc

Select query in zend framework 2.2 with multiple where clause and order by desc.
My query is
Select 'vch_no' from vaucher_mst where 'series_sno'=12 and vchtype_sno=13 order by vch_no,desc
How can I perform this query? Here is my try:
public function getvchno() {
$select = new select();
$select->from($this->table);
$this->select('vch_no');
$where = new where();
$where->equalTo('series_sno',12);
$where->equalTo('vchtype_sno',13);
$select->where($where);
$order_by='vch_no';
$order=Select::ORDER_DESCENDING;
$select->order($order_by . ' ' . $order);
$limit=1;
$select->LIMIT(1);
$statement = $this->select($select);
print_r($statement);die;
if (!$row) {
throw new \Exception("Could not find row $id");
}
}
I do not know Zend 2 but according to the doc, this should work:
// Select 'vch_no' from vaucher_mst where 'series_sno'=12 and vchtype_sno=13 order by vch_no,desc
$select = new Select();
$select->from('vaucher_mst')
->columns(array('vch_no'))
->where(array('series_sno = 12', 'vchtype_sno = 13'))
->order('vch_no DESC');
Keep me informed :)

left join with subqueries in laravel

How can i do to reproduce this sql statement below with query builder or eloquent? I've tried using DB::raw... and join('something', function ($join)... but it is not working. If anyone knows how to figure this out, please show me an example.
SELECT
musica.titulo,
p.qtd_pedidos,
a.qtd_avaliacoes,
a.media_avaliacoes
FROM
musica
LEFT JOIN (
SELECT musica_id, COUNT(pedido.id) as qtd_pedidos
FROM pedido GROUP BY pedido.musica_id
) as p ON p.musica_id = musica.id
LEFT JOIN (
SELECT musica_id, COUNT(avaliacao.id) as qtd_avaliacoes,
ROUND(AVG(avaliacao.nota),1) as media_avaliacoes
FROM avaliacao GROUP BY avaliacao.musica_id
) as a ON a.musica_id = musica.id
Assuming you have described Musica, Pedido and Avaliacao models with their relations:
Musica::with(
array('pedido' => function($query) {
$query->select(DB::raw('musica_id, COUNT(pedido.id) as qtd_pedidos'))
->groupBy('musica_id');
},
'avaliacao' => function($query) {
$query->select(DB::raw(
'musica_id, '
. 'COUNT(avaliacao.id) as qtd_avaliacoes, '
. 'ROUND(AVG(avaliacao.nota),1) as media_avaliacoes'
))
->groupBy('musica_id');
}
)
)->get();