Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Tracker/Db/Mysqli.php')
-rw-r--r--core/Tracker/Db/Mysqli.php29
1 files changed, 17 insertions, 12 deletions
diff --git a/core/Tracker/Db/Mysqli.php b/core/Tracker/Db/Mysqli.php
index 12ed3ed725..0fe9e4e7a1 100644
--- a/core/Tracker/Db/Mysqli.php
+++ b/core/Tracker/Db/Mysqli.php
@@ -8,6 +8,11 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Tracker\Db;
+
+use Exception;
+use Piwik\Tracker\Db;
+use Piwik\Tracker\Db\DbException;
/**
* mysqli wrapper
@@ -15,7 +20,7 @@
* @package Piwik
* @subpackage Tracker
*/
-class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
+class Mysqli extends Db
{
protected $connection = null;
protected $host;
@@ -64,7 +69,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
/**
* Connects to the DB
*
- * @throws Exception|Piwik_Tracker_Db_Exception if there was an error connecting the DB
+ * @throws Exception|DbException if there was an error connecting the DB
*/
public function connect()
{
@@ -74,11 +79,11 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
$this->connection = mysqli_connect($this->host, $this->username, $this->password, $this->dbname, $this->port, $this->socket);
if (!$this->connection || mysqli_connect_errno()) {
- throw new Piwik_Tracker_Db_Exception("Connect failed: " . mysqli_connect_error());
+ throw new DbException("Connect failed: " . mysqli_connect_error());
}
if ($this->charset && !mysqli_set_charset($this->connection, $this->charset)) {
- throw new Piwik_Tracker_Db_Exception("Set Charset failed: " . mysqli_error($this->connection));
+ throw new DbException("Set Charset failed: " . mysqli_error($this->connection));
}
$this->password = '';
@@ -105,7 +110,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
* @param string $query Query
* @param array $parameters Parameters to bind
* @return array
- * @throws Exception|Piwik_Tracker_Db_Exception if an exception occured
+ * @throws Exception|DbException if an exception occured
*/
public function fetchAll($query, $parameters = array())
{
@@ -118,7 +123,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
$query = $this->prepare($query, $parameters);
$rs = mysqli_query($this->connection, $query);
if (is_bool($rs)) {
- throw new Piwik_Tracker_Db_Exception('fetchAll() failed: ' . mysqli_error($this->connection) . ' : ' . $query);
+ throw new DbException('fetchAll() failed: ' . mysqli_error($this->connection) . ' : ' . $query);
}
while ($row = mysqli_fetch_array($rs, MYSQLI_ASSOC)) {
@@ -131,7 +136,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
}
return $rows;
} catch (Exception $e) {
- throw new Piwik_Tracker_Db_Exception("Error query: " . $e->getMessage());
+ throw new DbException("Error query: " . $e->getMessage());
}
}
@@ -145,7 +150,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
*
* @return array
*
- * @throws Piwik_Tracker_Db_Exception if an exception occurred
+ * @throws DbException if an exception occurred
*/
public function fetch($query, $parameters = array())
{
@@ -157,7 +162,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
$query = $this->prepare($query, $parameters);
$rs = mysqli_query($this->connection, $query);
if (is_bool($rs)) {
- throw new Piwik_Tracker_Db_Exception('fetch() failed: ' . mysqli_error($this->connection) . ' : ' . $query);
+ throw new DbException('fetch() failed: ' . mysqli_error($this->connection) . ' : ' . $query);
}
$row = mysqli_fetch_array($rs, MYSQLI_ASSOC);
@@ -168,7 +173,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
}
return $row;
} catch (Exception $e) {
- throw new Piwik_Tracker_Db_Exception("Error query: " . $e->getMessage());
+ throw new DbException("Error query: " . $e->getMessage());
}
}
@@ -179,7 +184,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
* @param array|string $parameters Parameters to bind array('idsite'=> 1)
*
* @return bool|resource false if failed
- * @throws Piwik_Tracker_Db_Exception if an exception occurred
+ * @throws DbException if an exception occurred
*/
public function query($query, $parameters = array())
{
@@ -203,7 +208,7 @@ class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
}
return $result;
} catch (Exception $e) {
- throw new Piwik_Tracker_Db_Exception("Error query: " . $e->getMessage() . "
+ throw new DbException("Error query: " . $e->getMessage() . "
In query: $query
Parameters: " . var_export($parameters, true));
}