Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated the version number of CodeInginer since which CUBRID support …

…is available. Added support for list_databases() function by overriding the parent function. Updated CUBRID version in comments.
  • Loading branch information...
commit b1388db1e388194f7e8d3a01e6b995a87205112c 1 parent e0b77de
Esen Sagynov authored February 10, 2012
58  system/database/drivers/cubrid/cubrid_utility.php
@@ -9,7 +9,7 @@
9 9
  * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
10 10
  * @license		http://codeigniter.com/user_guide/license.html
11 11
  * @link		http://codeigniter.com
12  
- * @since		Version 1.0
  12
+ * @since		Version 2.1
13 13
  * @filesource
14 14
  */
15 15
 
@@ -24,28 +24,32 @@
24 24
  */
25 25
 class CI_DB_cubrid_utility extends CI_DB_utility {
26 26
 
27  
-	/**
28  
-	 * List databases
29  
-	 *
30  
-	 * @access	private
31  
-	 * @return	array
32  
-	 */
33  
-	function _list_databases()
34  
-	{
35  
-		// CUBRID does not allow to see the list of all databases on the
36  
-		// server. It is the way its architecture is designed. Every
37  
-		// database is independent and isolated.
38  
-		// For this reason we can return only the name of the currect
39  
-		// connected database.
40  
-		if ($this->conn_id)
41  
-		{
42  
-			return "SELECT '" . $this->database . "'";
43  
-		}
44  
-		else
45  
-		{
46  
-			return FALSE;
47  
-		}
48  
-	}
  27
+    /**
  28
+     * List databases
  29
+     *
  30
+     * @access	public
  31
+     * @return	bool
  32
+     */
  33
+    function list_databases()
  34
+    {
  35
+        // Is there a cached result?
  36
+        if (isset($this->data_cache['db_names']))
  37
+        {
  38
+            return $this->data_cache['db_names'];
  39
+        }
  40
+
  41
+        $query = $this->db->query('SELECT LIST_DBS()');
  42
+        $dbs = array();
  43
+        if ($query->num_rows() > 0)
  44
+        {
  45
+            // CUBRID returns a list of databases in one row separated
  46
+            // by spaces.
  47
+            $dbs = explode(' ', current(current($query->result_array())));
  48
+        }
  49
+
  50
+        $this->data_cache['db_names'] = $dbs;
  51
+        return $this->data_cache['db_names'];
  52
+    }
49 53
 
50 54
 	// --------------------------------------------------------------------
51 55
 
@@ -57,11 +61,11 @@ function _list_databases()
57 61
 	 * @access	private
58 62
 	 * @param	string	the table name
59 63
 	 * @return	object
60  
-	 * @link 	http://www.cubrid.org/manual/840/en/Optimize%20Database
  64
+	 * @link 	http://www.cubrid.org/manual/841/en/Optimize%20Database
61 65
 	 */
62 66
 	function _optimize_table($table)
63 67
 	{
64  
-		// No SQL based support in CUBRID as of version 8.4.0. Database or
  68
+		// No SQL based support in CUBRID as of version 8.4.1. Database or
65 69
 		// table optimization can be performed using CUBRID Manager
66 70
 		// database administration tool. See the link above for more info.
67 71
 		return FALSE;
@@ -81,7 +85,7 @@ function _optimize_table($table)
81 85
 	 */
82 86
 	function _repair_table($table)
83 87
 	{
84  
-		// Not supported in CUBRID as of version 8.4.0. Database or
  88
+		// Not supported in CUBRID as of version 8.4.1. Database or
85 89
 		// table consistency can be checked using CUBRID Manager
86 90
 		// database administration tool. See the link above for more info.
87 91
 		return FALSE;
@@ -97,7 +101,7 @@ function _repair_table($table)
97 101
 	 */
98 102
 	function _backup($params = array())
99 103
 	{
100  
-		// No SQL based support in CUBRID as of version 8.4.0. Database or
  104
+		// No SQL based support in CUBRID as of version 8.4.1. Database or
101 105
 		// table backup can be performed using CUBRID Manager
102 106
 		// database administration tool.
103 107
 		return $this->db->display_error('db_unsuported_feature');

0 notes on commit b1388db

Please sign in to comment.
Something went wrong with that request. Please try again.