AntonTerekhov / OrientDB-PHP

Binary protocol for OrientDB for PHP applications (Beta)
http://code.google.com/p/orient/wiki/NetworkBinaryProtocol
BSD 3-Clause "New" or "Revised" License
108 stars 23 forks source link

can't access record in ajax using orientdb-php #51

Open Prashu33 opened 9 years ago

Prashu33 commented 9 years ago

try { $this->odb = new OrientDB('localhost',2424); $connect = $this->odb->connect('gms', 'gms123'); $clusters = $this->odb->DBOpen('gms', 'gms', 'gms123'); $records = $this->odb->query("select * from coupon_package where is_deleted = 0"); print_r( $records); }catch (OrientDBException $e) { die("internal"); }

response ouput:

Array ( [0] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 12 [recordPos:OrientDBRecord:private] => 10 [recordID:OrientDBRecord:private] => 12:10 [version] => 6 [content:OrientDBRecord:private] => coupon_package@is_deleted:false,package_name:"sdfsdere",no_of_coupons:123123,amount:1231232.0d,description:"gdvdsdfs",type:"Agency",created_date:1398191400000t [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] => 12 [recordPos:OrientDBRecord:private] => 11 [recordID:OrientDBRecord:private] => 12:11 [version] => 3 [content:OrientDBRecord:private] => coupon_package@is_deleted:false,package_name:"rdgervfdvsdf",no_of_coupons:23423423,amount:2.3131232E7d,description:"xcgdgdfddfvdf",type:"Agency",created_date:1398191400000t [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] => 12 [recordPos:OrientDBRecord:private] => 12 [recordID:OrientDBRecord:private] => 12:12 [version] => 3 [content:OrientDBRecord:private] => coupon_package@is_deleted:false,package_name:"sdfsfed",no_of_coupons:12312321,amount:221312.0d,description:"zxfasdfsdaf",type:"Agency",created_date:1398191400000t [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object RECURSION ) ) [3] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 12 [recordPos:OrientDBRecord:private] => 13 [recordID:OrientDBRecord:private] => 12:13 [version] => 3 [content:OrientDBRecord:private] => coupon_package@is_deleted:false,package_name:"sdfsdsdcasd",no_of_coupons:23423423,amount:2342423.0d,description:"xzfaxcasdcsd",type:"Agency",created_date:1398191400000t [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object RECURSION ) ) [4] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 12 [recordPos:OrientDBRecord:private] => 14 [recordID:OrientDBRecord:private] => 12:14 [version] => 1 [content:OrientDBRecord:private] => coupon_package@is_deleted:false,package_name:"sdfsdf",no_of_coupons:42342343,amount:2342343.0d,description:"sdfsdfsdcsdc",type:"Agency",created_date:1398191400000t [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object RECURSION ) ) [5] => OrientDBRecord Object ( [isParsed:OrientDBRecord:private] => [className:OrientDBRecord:private] => [type] => d [clusterID:OrientDBRecord:private] => 12 [recordPos:OrientDBRecord:private] => 15 [recordID:OrientDBRecord:private] => 12:15 [version] => 1 [content:OrientDBRecord:private] => coupon_package@is_deleted:false,package_name:"asdasds",no_of_coupons:123123,amount:312312.0d,description:"asddasd",type:"Agency",created_date:1398191400000t [data] => OrientDBData Object ( [data:OrientDBData:private] => Array ( ) [record:OrientDBData:private] => OrientDBRecord Object RECURSION ) ) )

After convert json format the output:

[{"type":"d","version":6,"data":{}},{"type":"d","version":3,"data":{}},{"type":"d","version":3,"data":{}},{"type":"d","version":3,"data":{}},{"type":"d","version":1,"data":{}},{"type":"d","version":1,"data":{}}]

please suggest me how to get properties value in data nodes

AntonTerekhov commented 9 years ago

Well, seems that json_encode() does not call $record-parse(), so you'd have to manually parse each record in array like

    foreach($records as $record) {
        $record->parse();
    }
    echo json_encode($records);

or create new array from each record's data attribute and encode this new array. Hope this will help.

Prashu33 commented 9 years ago

After doing this there is a message of Maximum execution time of 30 seconds exceeded. and didn't work.