On Nov 7, 2007, at 2:04 AM, James liu wrote:

i just decrease answer information...and u will see my result(full, not
part)

*before unserialize....*
string(433)
"a:2:{s:14:"responseHeader";a:3:{s:6:"status";i:0;s:5:"QTime";i: 0;s:6:"params";a:7:{s:2:"fl";s:5:"Title";s:6:"indent";s:2:"on";s: 5:"start";s:1:"0";s:1:"q";s:1:"2";s:2:"wt";s:4:"phps";s:4:"rows";a: 2:{i:0;s:1:"2";i:1;s:2:"10";}s:7:"version";s:3:" 2.2";}}s:8:"response";a:3:{s:8:"numFound";i:28;s:5:"start";i:0;s: 4:"docs";a:2:{i:0;a:1:{s:5:"Title";d:诺基亚N-Gage基本数据;}i:1;a:1: {s:5:"Title";d:索尼爱立信P908基本数据;}}}}"

*after unserialize...*
bool(false)


and i write serialize test code..

<?php
$ar = array (
    array('id' => 123, 'Title'=> "中文测试"),
    array('id' => 123, 'Title'=> "中国上海"),
);

echo serialize($ar);

?>



and result is :


a:2:{i:0;a:2:{s:2:"id";i:123;s:5:"Title";s:12:"中文测试";}i:1;a:2: {s:2:"id";i:123;s:5:"Title";s:12:"中国上海";}}




*php* result is:

string(369) "array( 'responseHeader'=>array( 'status'=>0, 'QTime'=>0,
'params'=>array( 'fl'=>'Title', 'indent'=>'on', 'start'=>'0', 'q'=>'2',
'wt'=>'php', 'rows'=>array('2', '10'), 'version'=>'2.2')),
'response'=>array('numFound'=>28,'start'=>0,'docs'=>array( array(
'Title'=>诺基亚N-Gage基本数据), array( 'Title'=>索尼爱立信P908基本数 据)) ))"

it is string, so i can't read it correctly by php.




This part (after string(369)) is exactly what it you should be seeing if you use the php handler, and it's what you get after you unserialize when using phps.

You can access your search results as:

$solrResults['response']['docs'];

In your example above, that would be:

array( array('Title'=>诺基亚N-Gage基本数据), array( 'Title'=>索尼爱立信 P908基本数据))

When using the php handler, you must do something like this:

eval('$solrResults = ' .$serializedSolrResults . ';');

Then, as above, you can access $solrResults['response']['docs'].

To sum up, if you use phps, you must unserialize the results. If you use php, you must eval the results (including some sugar to get a variable set to that value).


dave


Reply via email to