Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Prashu33 opened this issue Jun 3, 2015 · 2 comments
Open

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

Prashu33 opened this issue Jun 3, 2015 · 2 comments

Comments

@Prashu33
Copy link

Prashu33 commented Jun 3, 2015

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
Copy link
Owner

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
Copy link
Author

Prashu33 commented Jun 4, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants