From 94faca10aaf0e92091e924f08dd656d785da334e Mon Sep 17 00:00:00 2001 From: maximebf Date: Thu, 15 Aug 2013 00:13:39 +1000 Subject: [PATCH] fixed bug where the Db class would be wrapped inside a TraceablePDO object when DebugBar is actuvated --- src/plugins/DebugBar.php | 2 +- src/plugins/DebugBar/TraceableDb.php | 116 +++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/plugins/DebugBar/TraceableDb.php diff --git a/src/plugins/DebugBar.php b/src/plugins/DebugBar.php index 436bd33..75a3c0b 100644 --- a/src/plugins/DebugBar.php +++ b/src/plugins/DebugBar.php @@ -57,7 +57,7 @@ public static function onAtomikBootstrap() public static function onAtomikStart(&$cancel) { if (Atomik::isPluginLoaded('Db')) { - Atomik::set('db', new \DebugBar\DataCollector\PDO\TraceablePDO(Atomik::get('db'))); + Atomik::set('db', new \Atomik\DebugBar\TraceableDb(Atomik::get('db'))); self::$instance->addCollector(new \DebugBar\DataCollector\PDO\PDOCollector(Atomik::get('db'), self::$instance['time'])); } diff --git a/src/plugins/DebugBar/TraceableDb.php b/src/plugins/DebugBar/TraceableDb.php new file mode 100644 index 0000000..1b67a88 --- /dev/null +++ b/src/plugins/DebugBar/TraceableDb.php @@ -0,0 +1,116 @@ +pdo->executeSelect($tableName, $columns, $where, $afterWhere); + } + + /** + * Executes a SELECT * on $tableName and returns all rows as an array + * + * @param string $query + * @param array $where + * @param string $afterWhere + * @return array + */ + public function select($tableName, $where = null, $afterWhere = '') + { + return $this->pdo->select($tableName, $where, $afterWhere); + } + + /** + * Executes a SELECT * on $tableName and returns the first row + * + * @param string $query + * @param array $where + * @param string $afterWhere + * @return array + */ + public function selectOne($tableName, $where = null, $afterWhere = '') + { + return $this->pdo->selectOne($tableName, $where, $afterWhere); + } + + /** + * Executes a SELECT on $tableName and returns the first column of the first row + * + * @param string $query + * @param string $column + * @param array $where + * @return mixed + */ + public function selectValue($tableName, $column, $where = null) + { + return $this->pdo->selectValue($tableName, $column, $where); + } + + /** + * Executes a SELECT COUNT(*) on $tableName + * + * @param string $tableName + * @param array|string $where + * @return int + */ + public function count($tableName, $where = null) + { + return $this->pdo->count($tableName, $where); + } + + /** + * Inserts some data into the specified table + * + * @param string $tableName + * @param array $data + * @return Statement + */ + public function insert($tableName, array $data) + { + return $this->pdo->insert($tableName, $data); + } + + /** + * Updates the specified table matching the $where using $data + * + * @param string $tableName + * @param array $data + * @param array|string $where + * @return Statement + */ + public function update($tableName, array $data, $where = null) + { + return $this->pdo->update($tableName, $data, $where); + } + + /** + * Deletes row from a table + * + * @param string $tableName + * @param array|string $where + * @return Statement + */ + public function delete($tableName, $where = null) + { + return $this->pdo->delete($tableName, $where); + } +} \ No newline at end of file