SDK
SDK PHP v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

query #

Base method used to send queries to Kuzzle, following the API Documentation.

This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
Refer to Kuzzle's API Reference


query(queryArgs, query, [options], [callback]) #

ArgumentTypeDescription
queryArgsJSON objectQuery base arguments
queryJSON objectQuery to execute
optionsJSON objectOptional parameters
callbackfunctionOptional callback

queryArgs #

queryArgs is a JSON object allowing Kuzzle to route your query to the right API method:

OptionTypeDescriptionRequired?
controllerstringAPI Controller argumentrequired
actionstringAPI Controller actionrequired
indexstringIndex concerned by the actionoptional
collectionstringData collection concerned by the actionoptional

query #

query is a JSON object containing arguments specific to the query, such as a body property, a JWT hash, a document _id, or generic query options (such as from or size for search queries) #

Options #

OptionTypeDescriptionDefault
volatileJSON objectAdditional information passed to notifications to other usersnull
queuablebooleanMake this request queuable or nottrue

Return Value #

Returns the Kuzzle SDK object to allow chaining.


Callback Response #

Returns a JSON object containing the raw Kuzzle response.

Usage #

<?php
use \Kuzzle\Kuzzle;
$kuzzle = new Kuzzle('localhost');
$queryArgs = [
  'controller' => 'controller',
  'action' => 'action'
];
$query = [
  'body' => [
    'foo' => 'bar'
  ],
  'other' => 'argument'
];
try {
  $response = $kuzzle->query($queryArgs, $query);
}
catch (ErrorException $e) {
}

Callback response:

{
  "error": null,
  "result": {
    "action": "action",
    "controller": "controller",
    "requestId": "bf87b930-7c02-11e5-ab10-dfa9e9fd2e07",
    "other properties": "depends of the query made"
  }
}