tags:

views:

106

answers:

2

I've got a response form the solr query in php. below is the response form apache solr in drupal6, i need to access the id field inside the Apache_Solr_Document, can some bosy help me with this.

i was able to print this using print_r($result);

Array ( [type] => Bookmarks [node] => Apache_Solr_Document Object ( [_documentBoost:protected] => [_fields:protected] => Array ( [id] => b17692e4ad53/node/274 )))

if i do print_r($result[node]); i am getting

Apache_Solr_Document Object ( [_documentBoost:protected] => [_fields:protected] => Array ( [id] => b17692e4ad53/node/274 ))

from here i can't figure out how to access the id.

A: 

You can try using the {} brackets if the object name is not a valid object property name (like SimpleXML stuff).

$object->{'strang&$*#nmame'}->value;
Xeoncross
thanks, but i did this and it worked.$result[node]->id;
pmarreddy
@pmarreddy Make that an answer.
Christopher W. Allen-Poole
+3  A: 

Have you tried reading through IBM's article on Solr? The end of the article deals specifically with PHP.

Edit: After finding a source class to read through, it looks like you can do:

$result['node']->getField("id");

or using the magic __get:

$result['node']->id;
Justin Johnson
thanks for the additional info.
pmarreddy
glad i could help
Justin Johnson