Permalink
Browse files

drivers: getResource() and getResultResource() checks if resource is …

…alive
  • Loading branch information...
dg committed Jan 19, 2012
1 parent c7b9a91 commit 660a9db522ade6a3f0a13a995bb0252e4cfdfe5f
@@ -235,7 +235,7 @@ public function inTransaction()
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -359,7 +359,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -431,7 +431,7 @@ public function free()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
View
@@ -177,7 +177,7 @@ public function rollback($savepoint = NULL)
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -307,7 +307,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -387,7 +387,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
@@ -184,7 +184,7 @@ public function rollback($savepoint = NULL)
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -314,7 +314,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -393,7 +393,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
}
View
@@ -255,7 +255,7 @@ public function rollback($savepoint = NULL)
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -384,7 +384,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -473,7 +473,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
}
View
@@ -252,7 +252,7 @@ public function rollback($savepoint = NULL)
*/
public function getResource()
{
- return $this->connection;
+ return @$this->connection->thread_id ? $this->connection : NULL;
}
@@ -380,7 +380,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -479,7 +479,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return @$this->resultSet->type === NULL ? NULL : $this->resultSet;
}
}
View
@@ -200,7 +200,7 @@ public function inTransaction()
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -327,7 +327,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -417,7 +417,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
View
@@ -191,7 +191,7 @@ public function rollback($savepoint = NULL)
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -321,7 +321,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -400,7 +400,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
View
@@ -231,7 +231,7 @@ public function inTransaction()
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -374,7 +374,7 @@ public function applyLimit(&$sql, $limit, $offset)
*/
public function __destruct()
{
- $this->resultSet && @$this->free();
+ $this->getResultResource() && $this->free();
}
@@ -455,7 +455,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
View
@@ -202,7 +202,7 @@ public function rollback($savepoint = NULL)
*/
public function getResource()
{
- return $this->connection;
+ return is_resource($this->connection) ? $this->connection : NULL;
}
@@ -412,7 +412,7 @@ public function getResultColumns()
*/
public function getResultResource()
{
- return $this->resultSet;
+ return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
@@ -144,7 +144,7 @@ public function __construct($config, $name = NULL)
public function __destruct()
{
// disconnects and rolls back transaction - do not rely on auto-disconnect and rollback!
- $this->connected && $this->disconnect();
+ $this->connected && $this->driver->getResource() && $this->disconnect();
}
@@ -13,7 +13,9 @@
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'data/sample.sdb',
- 'profiler' => TRUE,
+ 'profiler' => array(
+ 'run' => TRUE,
+ )
));

0 comments on commit 660a9db

Please sign in to comment.