hmm....

i find error,,,that is my error not about php and phps ..

i use old config to test....so config have a problem..

that is Title i use double as its type...it should use text.


On Nov 8, 2007 10:29 AM, James liu <[EMAIL PROTECTED]> wrote:

>  php now is ok..
>
> but phps failed....
>
> mycode:
>
> > <?php
> >     $url = 
> > 'http://localhost:8080/solr1/select/?q=2&version=2.2&rows=2&fl=Title&start=0&rows=10&indent=on&wt=phps
> > ';
> >     $a = file_get_contents($url);
> >     //eval('$solrResults = ' .$serializedSolrResults . ';');
> >     echo '<b>before unserialize....</b><br/>';
> >     var_dump($a);
> >     echo '<Br/>';
> >     $a = unserialize($a);
> >     echo '<b>after unserialize...</b><br/>';
> >     var_dump($a);
> > ?>
> >
>
> and result:
>
> > *before unserialize....*
> > string(434)
> > "a:2:{s:14:"responseHeader";a:3:{s:6:"status";i:0;s:5:"QTime";i:32;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)
> >
>
>
> On Nov 7, 2007 9:30 PM, Dave Lewis <[EMAIL PROTECTED]> wrote:
>
> >
> > 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
> >
> >
> >
>
>
> --
> regards
> jl




-- 
regards
jl

Reply via email to