扩展PDO
将像任何其他类一样完成.这会满足你的需求吗?唯一的其他代码更改是PDO
在进行初始连接时必须实例化此类而不是类.
class PDOEx extends PDO
{
private $queryCount = 0;
public function query($query)
{
// Increment the counter.
++$this->queryCount;
// Run the query.
return parent::query($query);
}
public function exec($statement)
{
// Increment the counter.
++$this->queryCount;
// Execute the statement.
return parent::exec($statement);
}
public function GetCount()
{
return $this->queryCount;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2288 次 |
最近记录: |