This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bug where the Db class would be wrapped inside a TraceablePDO o…
…bject when DebugBar is actuvated
- Loading branch information
Showing
2 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
namespace Atomik\DebugBar; | ||
|
||
use DebugBar\DataCollector\PDO\TraceablePDO; | ||
use Atomik\Db; | ||
|
||
class TraceableDb extends TraceablePDO | ||
{ | ||
public function __construct(Db $db) | ||
{ | ||
parent::__construct($db); | ||
} | ||
|
||
/** | ||
* Executes a SELECT statement and returns the PDOStatement object | ||
* | ||
* @param string $query | ||
* @param string $columns | ||
* @param array $where | ||
* @param string $afterWhere | ||
* @return PDOStatement | ||
*/ | ||
public function executeSelect($tableName, $columns = '*', $where = null, $afterWhere = '') | ||
{ | ||
return $this->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); | ||
} | ||
} |