Skip to content

Error matching __key__ in GQL query #98

Open
@ajck

Description

@ajck

This is a failure with my GQL usage rather than php-gds I think, but I'm getting the error:
"__key__ filter value must be a Key" in my php logs when I do the following query:

$user_obj = $obj_store->query("SELECT * FROM Users WHERE __key__ = @userid", ['userid' => $userid])->fetchOne();

where $userid is the Datastore-assigned numeric key for that particular user from an earlier GQL query which I obtain with getKeyId() and is then stored in the PHP $_SESSION.

I tried changing the query to:

$user_obj = $obj_store->query("SELECT * FROM Users WHERE __key__ = KEY(Users, ".$userid.")");

but got the error:
"Argument 1 passed to GDS\Gateway::putMulti() must be of the type array, object given"

Any suggestions much appreciated!

Also, I'm not clear on when I should use (in a WHERE clause): __key__ = KEY(Store, item-to-match) vs. __key__ = @param", ['param'] => $item-to-match

Many thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions