1 | <?php |
||
14 | class Connection extends ConnectionBase |
||
15 | { |
||
16 | /** |
||
17 | * Performs a query on the Sphinx server. |
||
18 | * |
||
19 | * @param string $query The query string |
||
20 | * |
||
21 | * @throws DatabaseException |
||
22 | * @return array|int The result array or number of rows affected |
||
23 | */ |
||
24 | public function query($query) |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | public function connect() |
||
44 | { |
||
45 | $params = $this->getParams(); |
||
46 | |||
47 | $dsn = 'mysql:'; |
||
48 | if (isset($params['host']) && $params['host'] != '') { |
||
49 | $dsn .= 'host=' . $params['host'] . ';'; |
||
50 | } |
||
51 | if (isset($params['port'])) { |
||
52 | $dsn .= 'port=' . $params['port'] . ';'; |
||
53 | } |
||
54 | if (isset($params['charset'])) { |
||
55 | $dsn .= 'charset=' . $params['charset'] . ';'; |
||
56 | } |
||
57 | |||
58 | if (isset($params['socket']) && $params['socket'] != '') { |
||
59 | $dsn .= 'unix_socket=' . $params['socket'] . ';'; |
||
60 | } |
||
61 | |||
62 | try { |
||
63 | $con = new \Pdo($dsn); |
||
64 | } catch (\PDOException $exception) { |
||
65 | throw new ConnectionException($exception->getMessage()); |
||
66 | } |
||
67 | |||
68 | $this->connection = $con; |
||
69 | $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
||
70 | |||
71 | return true; |
||
72 | } |
||
73 | |||
74 | public function ping() |
||
80 | |||
81 | /** |
||
82 | * @param array $queue |
||
83 | * @return \Foolz\SphinxQL\Drivers\Pdo\MultiResultSet |
||
84 | * @throws DatabaseException |
||
85 | * @throws SphinxQLException |
||
86 | */ |
||
87 | public function multiQuery(array $queue) |
||
103 | |||
104 | /** |
||
105 | * @param string $value |
||
106 | * @return string |
||
107 | */ |
||
108 | public function escape($value) |
||
114 | } |
||
115 |