如何 'SELECT' 来自 orient db 的数据并使用 php 显示它
How to 'SELECT' data from orient db and display it using php
我正在尝试 select 从 orient db 数据库中插入数据并将其回显出来?
我如何使用 php 来做到这一点?
这是我目前所做的
require('OrientDB/OrientDB.php');
$db = new OrientDB('localhost', 2424);
$connected = $db->connect('root', 'hello');
$config = $db->DBOpen('tabe', 'root', 'hello');
if($connected)
{
$records = $db->query("select from Nation");
echo $records;
}
else
{
die('Server Error');
}
它只是在屏幕上打印 'Array'
我是 运行 windows 机器上的 Apache php 服务器。
如何从数据库中获取数据并在网站上打印。
当我使用 for each 循环打印出元素时
我的脚本刚刚超时
$records = $db->query("select from Nation");
foreach ($records as $v)
echo $v;
如果我使用 print_r($records);
它给出以下输出
Array ( [0] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 169 [recordPos:OrientDBRecord:private] => 0 [recordID:OrientDBRecord:private] => 169:0 [version] => 4 [content:OrientDBRecord:private] => Nation@in_partOf:%AQAAAAIAwQAAAAAAAAAAAMIAAAAAAAAAAA==;,Country_Name:"India",Iso_code:"IN" [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object *RECURSION* ) ) [1] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 170 [recordPos:OrientDBRecord:private] => 0 [recordID:OrientDBRecord:private] => 170:0 [version] => 4 [content:OrientDBRecord:private] => Nation@Country_Name:"United States of America",Iso_code:"US" [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object *RECURSION* ) ) [2] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 171 [recordPos:OrientDBRecord:private] => 0 [recordID:OrientDBRecord:private] => 171:0 [version] => 2 [content:OrientDBRecord:private] => Nation@Country_Name:"Canada",Iso_code:"CA" [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object *RECURSION* ) ) )
如何将其转换为 suitable 形式。就像只取名字
这是我的table
打印结果。而不是 echo
print_r($records);
为了迭代结果,使用 foreach
或 for
首先检查我们是否有一些结果,使用 foreach
作为 :
if(count($records) > 0){//check if we have a result
foreach($records as $value){//loop
print_r($value);
}
}
最好使用PhpOrient库它是orient db
官方支持的库
$client = new PhpOrient();
$client->hostname = 'localhost';
$client->port = 2424;
$client->username = 'your_username';
$client->password = 'your_password';
$client->connect();
$client->dbOpen('Your_db_name');
$query = "SELECT FROM NATION";
$result = $client->query($query);
$result = json_encode($result);
$result = json_decode($result);
foreach ($result as $row){
echo $row->oData->Country_Name;
echo $row->oData->Iso_code;
}
phporient : https://github.com/orientechnologies/PhpOrient.git
我正在尝试 select 从 orient db 数据库中插入数据并将其回显出来? 我如何使用 php 来做到这一点?
这是我目前所做的
require('OrientDB/OrientDB.php');
$db = new OrientDB('localhost', 2424);
$connected = $db->connect('root', 'hello');
$config = $db->DBOpen('tabe', 'root', 'hello');
if($connected)
{
$records = $db->query("select from Nation");
echo $records;
}
else
{
die('Server Error');
}
它只是在屏幕上打印 'Array'
我是 运行 windows 机器上的 Apache php 服务器。 如何从数据库中获取数据并在网站上打印。
当我使用 for each 循环打印出元素时
我的脚本刚刚超时
$records = $db->query("select from Nation");
foreach ($records as $v)
echo $v;
如果我使用 print_r($records);
它给出以下输出
Array ( [0] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 169 [recordPos:OrientDBRecord:private] => 0 [recordID:OrientDBRecord:private] => 169:0 [version] => 4 [content:OrientDBRecord:private] => Nation@in_partOf:%AQAAAAIAwQAAAAAAAAAAAMIAAAAAAAAAAA==;,Country_Name:"India",Iso_code:"IN" [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object *RECURSION* ) ) [1] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 170 [recordPos:OrientDBRecord:private] => 0 [recordID:OrientDBRecord:private] => 170:0 [version] => 4 [content:OrientDBRecord:private] => Nation@Country_Name:"United States of America",Iso_code:"US" [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object *RECURSION* ) ) [2] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 171 [recordPos:OrientDBRecord:private] => 0 [recordID:OrientDBRecord:private] => 171:0 [version] => 2 [content:OrientDBRecord:private] => Nation@Country_Name:"Canada",Iso_code:"CA" [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object *RECURSION* ) ) )
如何将其转换为 suitable 形式。就像只取名字
这是我的table
打印结果。而不是 echo
print_r($records);
为了迭代结果,使用 foreach
或 for
首先检查我们是否有一些结果,使用 foreach
作为 :
if(count($records) > 0){//check if we have a result
foreach($records as $value){//loop
print_r($value);
}
}
最好使用PhpOrient库它是orient db
官方支持的库 $client = new PhpOrient();
$client->hostname = 'localhost';
$client->port = 2424;
$client->username = 'your_username';
$client->password = 'your_password';
$client->connect();
$client->dbOpen('Your_db_name');
$query = "SELECT FROM NATION";
$result = $client->query($query);
$result = json_encode($result);
$result = json_decode($result);
foreach ($result as $row){
echo $row->oData->Country_Name;
echo $row->oData->Iso_code;
}
phporient : https://github.com/orientechnologies/PhpOrient.git