From 76e0435af10579afdc3ed4956aeafa83a17decd3 Mon Sep 17 00:00:00 2001
From: Timothy Warren <tim@timshomepage.net>
Date: Tue, 14 Feb 2012 11:55:17 -0500
Subject: First iteration of interbase driver

---
 .../drivers/interbase/interbase_utility.php        | 108 +++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 system/database/drivers/interbase/interbase_utility.php

(limited to 'system/database/drivers/interbase/interbase_utility.php')

diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
new file mode 100644
index 000000000..533a269b2
--- /dev/null
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -0,0 +1,108 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * NOTICE OF LICENSE
+ * 
+ * Licensed under the Open Software License version 3.0
+ * 
+ * This source file is subject to the Open Software License (OSL 3.0) that is
+ * bundled with this package in the files license.txt / license.rst.  It is
+ * also available through the world wide web at this URL:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to
+ * licensing@ellislab.com so we can send you a copy immediately.
+ *
+ * @package		CodeIgniter
+ * @author		EllisLab Dev Team
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
+ * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link		http://codeigniter.com
+ * @since		Version 3.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Interbase/Firebird Utility Class
+ *
+ * @category	Database
+ * @author		EllisLab Dev Team
+ * @link		http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_interbase_utility extends CI_DB_utility {
+
+	/**
+	 * List databases
+	 *
+	 * I don't believe you can do a database listing with Firebird
+	 * since each database is its own file.  I suppose we could
+	 * try reading a directory looking for Firebird files, but
+	 * that doesn't seem like a terribly good idea
+	 *
+	 * @access	private
+	 * @return	bool
+	 */
+	function _list_databases()
+	{
+		if ($this->db_debug)
+		{
+			return $this->db->display_error('db_unsuported_feature');
+		}
+		return array();
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Optimize table query
+	 *
+	 * Is optimization even supported in Interbase/Firebird?
+	 *
+	 * @access	private
+	 * @param	string	the table name
+	 * @return	object
+	 */
+	function _optimize_table($table)
+	{
+		return FALSE;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Repair table query
+	 *
+	 * Table repairs are not supported in Interbase/Firebird
+	 *
+	 * @access	private
+	 * @param	string	the table name
+	 * @return	object
+	 */
+	function _repair_table($table)
+	{
+		return FALSE;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Interbase/Firebird Export
+	 *
+	 * @access	private
+	 * @param	array	Preferences
+	 * @return	mixed
+	 */
+	function _backup($params = array())
+	{
+		// Currently unsupported
+		return $this->db->display_error('db_unsuported_feature');
+	}
+}
+
+/* End of file interbase_utility.php */
+/* Location: ./system/database/drivers/interbase/interbase_utility.php */
\ No newline at end of file
-- 
cgit v1.2.3-24-g4f1b


From 4be822bcca94273967abf010ef67f64ead5e6bf2 Mon Sep 17 00:00:00 2001
From: Timothy Warren <tim@timshomepage.net>
Date: Tue, 14 Feb 2012 12:07:34 -0500
Subject: Added public declarations

---
 system/database/drivers/interbase/interbase_utility.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'system/database/drivers/interbase/interbase_utility.php')

diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index 533a269b2..d90ecae71 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -47,7 +47,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 * @access	private
 	 * @return	bool
 	 */
-	function _list_databases()
+	public function _list_databases()
 	{
 		if ($this->db_debug)
 		{
@@ -67,7 +67,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 * @param	string	the table name
 	 * @return	object
 	 */
-	function _optimize_table($table)
+	public function _optimize_table($table)
 	{
 		return FALSE;
 	}
@@ -83,7 +83,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 * @param	string	the table name
 	 * @return	object
 	 */
-	function _repair_table($table)
+	public function _repair_table($table)
 	{
 		return FALSE;
 	}
@@ -97,7 +97,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 * @param	array	Preferences
 	 * @return	mixed
 	 */
-	function _backup($params = array())
+	public function _backup($params = array())
 	{
 		// Currently unsupported
 		return $this->db->display_error('db_unsuported_feature');
-- 
cgit v1.2.3-24-g4f1b


From 498fa354888c1fc4083d1e464b651498d9338b64 Mon Sep 17 00:00:00 2001
From: Timothy Warren <tim@timshomepage.net>
Date: Wed, 15 Feb 2012 10:05:49 -0500
Subject: Minor codestyle fix

---
 system/database/drivers/interbase/interbase_utility.php | 1 +
 1 file changed, 1 insertion(+)

(limited to 'system/database/drivers/interbase/interbase_utility.php')

diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index d90ecae71..764275567 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -100,6 +100,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	public function _backup($params = array())
 	{
 		// Currently unsupported
+		// @todo See if can be implemented
 		return $this->db->display_error('db_unsuported_feature');
 	}
 }
-- 
cgit v1.2.3-24-g4f1b


From 817af19bb12b88bae361034e00ce3a02da595f94 Mon Sep 17 00:00:00 2001
From: Timothy Warren <tim@timshomepage.net>
Date: Thu, 16 Feb 2012 08:28:00 -0500
Subject: narfbg suggested fixes

---
 system/database/drivers/interbase/interbase_utility.php | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

(limited to 'system/database/drivers/interbase/interbase_utility.php')

diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index 764275567..e31021acb 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -44,7 +44,6 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 * try reading a directory looking for Firebird files, but
 	 * that doesn't seem like a terribly good idea
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
 	public function _list_databases()
@@ -53,7 +52,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 		{
 			return $this->db->display_error('db_unsuported_feature');
 		}
-		return array();
+		return FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -63,7 +62,6 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 *
 	 * Is optimization even supported in Interbase/Firebird?
 	 *
-	 * @access	private
 	 * @param	string	the table name
 	 * @return	object
 	 */
@@ -79,7 +77,6 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	 *
 	 * Table repairs are not supported in Interbase/Firebird
 	 *
-	 * @access	private
 	 * @param	string	the table name
 	 * @return	object
 	 */
@@ -93,7 +90,6 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	/**
 	 * Interbase/Firebird Export
 	 *
-	 * @access	private
 	 * @param	array	Preferences
 	 * @return	mixed
 	 */
-- 
cgit v1.2.3-24-g4f1b


From ab189e162f20f1a7daae8bfd2b921e694c3f9df3 Mon Sep 17 00:00:00 2001
From: Timothy Warren <tim@timshomepage.net>
Date: Wed, 22 Feb 2012 10:34:23 -0500
Subject: Close services after using them, added dbutil->backup() method

---
 .../database/drivers/interbase/interbase_utility.php | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

(limited to 'system/database/drivers/interbase/interbase_utility.php')

diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index e31021acb..76a0497c1 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -90,14 +90,24 @@ class CI_DB_interbase_utility extends CI_DB_utility {
 	/**
 	 * Interbase/Firebird Export
 	 *
-	 * @param	array	Preferences
+	 * @param	string	$filename
 	 * @return	mixed
 	 */
-	public function _backup($params = array())
+	public function backup($filename)
 	{
-		// Currently unsupported
-		// @todo See if can be implemented
-		return $this->db->display_error('db_unsuported_feature');
+		if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
+		{
+			$res = ibase_backup($service, $this->db->database, $filename.'.fbk');
+			
+			//Close the service connection	
+			ibase_service_detach($service);
+			
+			return $res;
+		}
+		else
+		{
+			return FALSE;
+		}
 	}
 }
 
-- 
cgit v1.2.3-24-g4f1b