Improve DB field_data() for MySQL and CUBRID
diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php
index 30aed38..130eea2 100644
--- a/system/database/drivers/cubrid/cubrid_result.php
+++ b/system/database/drivers/cubrid/cubrid_result.php
@@ -88,20 +88,14 @@
 	public function field_data()
 	{
 		$retval = array();
-		$i = 0;
 
-		while ($field = cubrid_fetch_field($this->result_id))
+		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
 		{
 			$retval[$i]			= new stdClass();
-			$retval[$i]->name		= $field->name;
-			// CUBRID returns type as e.g. varchar(100),
-			// so we need to remove all digits and brackets.
-			$retval[$i]->type		= preg_replace('/[\d()]/', '', $field->type);
-			$retval[$i]->default		= $field->def;
-			// Use CUBRID's native API to obtain column's max_length,
-			// otherwise $field->max_length has incorrect info
+			$retval[$i]->name		= cubrid_field_name($this->result_id, $i);
+			$retval[$i]->type		= cubrid_field_type($this->result_id, $i);
 			$retval[$i]->max_length		= cubrid_field_len($this->result_id, $i);
-			$retval[$i++]->primary_key	= $field->primary_key;
+			$retval[$i]->primary_key	= (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE);
 		}
 
 		return $retval;