2
我有一個數據庫名爲提名其中有一些字段數的數如何在現場
它命名爲「noinatedUnder」字段有一個我該怎麼讓插件的數量,那場
這是 SELECT的原始文本FROM提名人
{
"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)"
}
在此上的第一個條目出現在在 - 11個entrys>下面積和提名0對一切如何使用SQL的每個字段
即選中這個數字應該打印
-----------
count | ----------
11
0
0
0
我沒有得到使用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;
}
}
那麼結果是有什麼辦法直接從sql它自己計數,如從提名人選擇計數(*)給出提名人數
你試過什麼了?解決你的要求! – RiggsFolly
你有沒有遇到['json_decode()'](http://php.net/manual/en/function.json-decode.php)還沒有在您的旅行 – RiggsFolly
我已經更新我的答案請檢查 –