1 <?php
2
3 /**
4 * ArangoDB PHP client: query handling
5 *
6 * @package triagens\ArangoDb
7 * @author Jan Steemann
8 * @copyright Copyright 2015, triagens GmbH, Cologne, Germany
9 */
10
11 namespace triagens\ArangoDb;
12
13 class QueryHandler extends
14 Handler
15 {
16 /**
17 * Clears the list of slow queries
18 *
19 * @throws Exception
20 */
21 public function clearSlow()
22 {
23 $url = UrlHelper::buildUrl(Urls::URL_QUERY, ['slow']);
24 $this->getConnection()->delete($url);
25 }
26
27 /**
28 * Returns the list of slow queries
29 *
30 * @throws Exception
31 *
32 * @return array
33 */
34 public function getSlow()
35 {
36 $url = UrlHelper::buildUrl(Urls::URL_QUERY, ['slow']);
37 $response = $this->getConnection()->get($url);
38
39 return $response->getJson();
40 }
41
42 /**
43 * Returns the list of currently executing queries
44 *
45 * @throws Exception
46 *
47 * @return array
48 */
49 public function getCurrent()
50 {
51 $url = UrlHelper::buildUrl(Urls::URL_QUERY, ['current']);
52 $response = $this->getConnection()->get($url);
53
54 return $response->getJson();
55 }
56
57 /**
58 * Kills a specific query
59 *
60 * This will send an HTTP DELETE command to the server to terminate the specified query
61 *
62 * @param string $id - query id
63 *
64 * @throws Exception
65 *
66 * @return bool
67 */
68 public function kill($id)
69 {
70 $url = UrlHelper::buildUrl(Urls::URL_QUERY, [$id]);
71 $this->getConnection()->delete($url);
72
73 return true;
74 }
75
76 }
77