I have a data base named nominator which has some fields
it have a in field named 'noinatedUnder' how can i show the number of inS to that field
this is the Raw text of SELECT FROM Nominator
{
"result": [
{
"@type": "d",
"@rid": "#73:2",
"@version": 2,
"@class": "Nominator",
"isTemp": "true",
"id": "JJRXW",
"Email": "[email protected]",
"Name": "nijeesh",
"Phone": "7894561234",
"school": "#65:2",
"in_noinatedUnder": [
"#161:1",
"#162:1",
"#163:1",
"#164:0",
"#165:0",
"#166:0",
"#167:0",
"#168:0",
"#161:0",
"#162:0",
"#163:0"
],
"@fieldTypes": "school=x,in_noinatedUnder=g"
},
{
"@type": "d",
"@rid": "#74:0",
"@version": 1,
"@class": "Nominator",
"isTemp": "true",
"id": "SU7SV",
"Email": "[email protected]",
"Name": "pon muthu",
"Phone": "7778455215",
"school": "#65:2",
"@fieldTypes": "school=x"
},
{
"@type": "d",
"@rid": "#75:1",
"@version": 1,
"@class": "Nominator",
"isTemp": "true",
"id": "4DZ86",
"Email": "[email protected]",
"Name": "sivaraj",
"Phone": "7788899445",
"school": "#65:2",
"@fieldTypes": "school=x"
},
{
"@type": "d",
"@rid": "#76:1",
"@version": 1,
"@class": "Nominator",
"isTemp": "true",
"id": "HFQJ1",
"Email": "[email protected]",
"Name": "dbhbsd",
"Phone": "8656548745",
"school": "#65:2",
"@fieldTypes": "school=x"
}
],
"notification": "Query executed in 6.12 sec. Returned 4 record(s)"
}
in this on the first entry there is 11 entrys in the in->nominated under area and 0 on everything else how to select this number using sql for each field
that is it should print
-----------
count | ----------
11
0
0
0
i did got the result using php
$query = "select * from `Nominator`";
$result = runquery($query);
$a = array();
for($i=0;$i<sizeof($result);$i++)
{
echo '<p>';
echo isset($result[$i]->oData->in_noinatedUnder)?sizeof($result[$i]->oData->in_noinatedUnder):0;
echo '</p>';
}
function runquery($query)
{
$client = new PhpOrient();
$client->hostname = 'localhost';
$client->port = 2424;
$client->username = 'root';
$client->password = 'hello';
$client->connect();
$client->dbOpen('tabe');
$result = $client->query($query);
$json = json_decode(json_encode($result));
if (sizeof($json) > 0) {
return $json;
} else {
return false;
}
}
So is there any way to get the count directly from sql it self, like select count(*) from nominator gives count of nominators
To get the number of vertexes in in try this query:
select in().size() from <class-name>
Hope it helps.
Regards