[Developers] PHP Integration Problems
Chris Mahon
darthmahon at gmail.com
Thu Jan 3 07:27:44 UTC 2008
Hi Guys,
Tim - thanks for the info, I'll look into MQL Cursors.
Chris - I checked to see if the query produced was the same and I believe it
is. This is what PHP outputs:
{"qname":{"query":[{"\/common\/topic\/image":[{"optional":true,"id":null}],"type":"\/cvg\/computer_videogame","name":null,"id":null,"sort":"name","release_date":[],"cvg_genre":[],"versions":{"platform":{"id":null,"name":null,"name~=":"Xbox
360"}},"limit":150}]}}
I ran the above query in freebase and it produced results. This is the PHP
that passes my query through:
// Put the query into an envelope object
$envelope = array("qname" => array("query" => $queryobj));
// Serialize the envelope object to JSON text
$querytext = $this->json->encode($envelope);
Thanks,
Chris
On Jan 3, 2008 12:25 AM, Chris Eppstein <chris at eppsteins.net> wrote:
> I wonder if the problem is just that the query isn't being placed
> within the request envelope. That would make it work in the editor but
> not via code. The request you send via mqlread should look like this
> { 'qname' : { 'query' : query_in_the_query_editor }}
>
> This was a gotcha for me on a couple of occasions until I abstracted
> it away.
>
> -chris
>
>
> On Jan 2, 2008, at 2:22 PM, Tim Kientzle wrote:
>
> > If you get no results without the limit, it's probably timing out on
> > the server.
> >
> > You'll need to use a cursor to request "pages" of data at a time. On
> > freebase.com,
> > search for "MQL Cursors" and you'll get a few useful hits, including
> > some examples:
> >
> > http://www.freebase.com/view/search?limit=30&start=0&query=mql+cursor
> >
> > You should probably start with the documentation here:
> >
> > http://www.freebase.com/view/guid/9202a8c04000641f800000000544e139
> >
> >
> >
> > On Jan 2, 2008, at 1:12 PM, Chris Mahon wrote:
> >
> >> Hi Chris,
> >>
> >> Thanks for the reply. Starting to make more sense, I can't see how I
> >> would use games_on_this_platform then? I.E. what can I do with it?
> >> My query was the same as on the Query Builder/Editor which did
> >> return results so it was odd that PHP did not. Anyway, I've made
> >> good progress and now have results coming back!
> >>
> >> One quick question though. I am adding a limit to my query, above
> >> the default 100. However when I do this it does not return results
> >> for my query. If I take the limit out, I get results. Any ideas? Is
> >> there a way of getting it to return ALL matches without limit?
> >>
> >> Query is now as follows:
> >>
> >> $q2 = array(array("/common/topic/image" => array(array("optional" =>
> >> true, "id" => null)),
> >> "type" =>
> "/cvg/computer_videogame",
> >> "name" => null,
> >> "id" => null,
> >> "sort" => "name",
> >> "release_date" => array(),
> >> "cvg_genre" => array(),
> >> "versions" => array("platform" =>
> array("id" => null, "name"
> >> => null, "name~=" => "Xbox 360")),
> >> "limit" => 150
> >> ));
> >>
> >> Cheers,
> >> Chris
> >>
> >> On Jan 1, 2008 5:53 PM, Christopher R. Maden <crism at metaweb.com>
> >> wrote:
> >> Chris Mahon <darthmahon at gmail.com> wrote:
> >>> I'm currently building a search page for computer games and have
> >> come across
> >>> some teething problems whilst using freebase.
> >>>
> >>> This is the query I based that on from within the freebase query
> >> builder:
> >>>
> >>> [{
> >>> "type":"/cvg/cvg_platform",
> >>> "games_on_this_platform":[{ "game":[{ "name":null }] }],
> >>> "name":"Xbox 360"
> >>> }]
> >>
> >> Happy new year, Chris. The problem with using foreach on the result
> >> of that query is that it returns a single thing: the platform called
> >> "Xbox 360." Now, it has a number of games on that platform, but the
> >> root of the query is just the platform itself.
> >>
> >> You can turn the query inside-out, to find games whose platform is
> >> the Xbox 360, or you can iterate over the games on that platform,
> >> instead of iterating over the platform itself.
> >>
> >> ~Chris
> >> --
> >> Christopher R. Maden
> >> Data Architect
> >> Metaweb Technologies, Inc.
> >> <URL: http://www.metaweb.com/ >
> >> _______________________________________________
> >> Developers mailing list
> >> Developers at freebase.com
> >> http://lists.freebase.com/mailman/listinfo/developers
> >>
> >> _______________________________________________
> >> Developers mailing list
> >> Developers at freebase.com
> >> http://lists.freebase.com/mailman/listinfo/developers
> >
> > _______________________________________________
> > Developers mailing list
> > Developers at freebase.com
> > http://lists.freebase.com/mailman/listinfo/developers
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20080103/f7daae08/attachment-0001.htm
More information about the Developers
mailing list