问题
$query = "SELECT * FROM Name";
works perfectly as expected but:
$query = "SELECT * FROM Name WHERE name = 'david'";
doesn't work as expected. The DataStore is created as follows:
$obj_name = new Entity();
$obj_name->name = strtolower($name);
$obj_name->age = $age;
$result = $obj_name_store->upsert($obj_name);
Any suggestions for how to extract a specific item using GQL?
Thank you.
回答1:
It looks like you are using my php-gds
library from here: https://github.com/tomwalder/php-gds
If so, then the problem is likely that you have not explicity requested the "name" property be indexed by Datastore.
When defining your Schema, you need to pass the optional second parameter "TRUE" in order for queries to work against those fields.
See here for a code example.
https://github.com/tomwalder/php-gds#defining-your-model
来源:https://stackoverflow.com/questions/28658555/appengine-datastore-gql-not-returning-any-results