added reconnect() method to db drivers
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index ddc036d..241b280 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -82,7 +82,23 @@
}
// --------------------------------------------------------------------
+
+ /**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ // not implemented in MSSQL
+ }
+ // --------------------------------------------------------------------
+
/**
* Select the database
*
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 2b05c3f..334daf3 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -91,6 +91,25 @@
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ if (mysql_ping($this->conn_id) === FALSE)
+ {
+ $this->conn_id = FALSE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Select the database
*
* @access private called by the base class
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 6558112..74cfff4 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -91,6 +91,25 @@
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ if (mysqli_ping($this->conn_id) === FALSE)
+ {
+ $this->conn_id = FALSE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Select the database
*
* @access private called by the base class
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 4dfec2e..f4ef42a 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -98,6 +98,22 @@
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ // not implemented in oracle
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Select the database
*
* @access private called by the base class
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index f7db4ca..2e529f3 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -82,6 +82,22 @@
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ // not implemented in odbc
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Select the database
*
* @access private called by the base class
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 4bc5b7d..db3a3f2 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -102,6 +102,25 @@
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ if (pg_ping($this->conn_id) === FALSE)
+ {
+ $this->conn_id = FALSE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Select the database
*
* @access private called by the base class
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index bb1e6d0..cd7b26b 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -100,6 +100,22 @@
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ // not implemented in SQLite
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Select the database
*
* @access private called by the base class
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index cdbfbbd..3ddaf8d 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -74,6 +74,7 @@
<li>Updated all database drivers to handle arrays in escape_str()</li>
<li>Added escape_like_str() method for escaping strings to be used in LIKE conditions</li>
<li>Updated Active Record to utilize the new LIKE escaping mechanism.</li>
+ <li>Added reconnect() method to DB drivers to try to keep alive / reestablish a connection after a long idle.</li>
</ul>
</li>
diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html
index 3579e1a..b4d5179 100644
--- a/user_guide/database/connecting.html
+++ b/user_guide/database/connecting.html
@@ -158,6 +158,11 @@
</div>
+<h2>Reconnecting / Keeping the Connection Alive</h2>
+
+<p>If the database server's idle timeout is exceeded while you're doing some heavy PHP lifting (processing an image, for instance), you should consider pinging the server by using the <dfn>reconnect()</dfn> method before sending further queries, which can gracefully keep the connection alive or re-establish it.</p>
+
+<code>$this->db->reconnect();</code>