Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use CUBRID's native API function to obtain column's max_length.

  • Loading branch information...
commit 80f8244cbe9789deb346a37b4297165bd432c874 1 parent 1ee9ccf
Esen Sagynov authored February 10, 2012
16  system/database/drivers/cubrid/cubrid_result.php
@@ -90,20 +90,20 @@ function list_fields()
90 90
 	function field_data()
91 91
 	{
92 92
 		$retval = array();
  93
+		$colIdx = 0;
93 94
 
94 95
 		while ($field = @cubrid_fetch_field($this->result_id))
95 96
 		{
96  
-			preg_match('/([a-zA-Z]+)(\((\d+)\))?/', $field->type, $matches);
97  
-
98  
-			$length = isset($matches[2]) ? (int)$matches[3] : false;
99  
-
100 97
 			$F              = new stdClass();
101 98
 			$F->name        = $field->name;
102  
-			$F->type        = $matches[1];
  99
+			// CUBRID returns type as varchar(100) for example,
  100
+			// that's why we need to remove all brackets and digits.
  101
+			$F->type        = preg_replace('/[\d()]/', '', $field->type);
103 102
 			$F->default     = $field->def;
104  
-			// if length is not specified like in case of TIMESTAMP
105  
-			// fall back to what API returns.
106  
-			$F->max_length  = $length ? $length : $field->max_length;
  103
+			// use CUBRID's native API to obtain column's max_length,
  104
+			// otherwise $field->max_length returns incorrect info.
  105
+			// See #150.
  106
+			$F->max_length  = cubrid_field_len($this->result_id, $colIdx++);
107 107
 			$F->primary_key = $field->primary_key;
108 108
 
109 109
 			$retval[] = $F;

0 notes on commit 80f8244

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