/** * Fetch the result * @param resource $result * @param int|NULL $arrayIndexEndValue * @return array */ function _fetch($result, $arrayIndexEndValue = NULL) { $output = array(); if (!$this->isConnected() || $this->isError() || !$result) { return array(); } if ($this->use_prepared_statements == 'Y') { } // TODO Improve this piece of code // This code trims values from char type columns $col_types = cubrid_column_types($result); $col_names = cubrid_column_names($result); $max = count($col_types); for ($count = 0; $count < $max; $count++) { if (preg_match("/^char/", $col_types[$count]) > 0) { $char_type_fields[] = $col_names[$count]; } } while ($tmp = cubrid_fetch($result, CUBRID_OBJECT)) { if (is_array($char_type_fields)) { foreach ($char_type_fields as $val) { $tmp->{$val} = rtrim($tmp->{$val}); } } if ($arrayIndexEndValue) { $output[$arrayIndexEndValue--] = $tmp; } else { $output[] = $tmp; } } unset($char_type_fields); if ($result) { cubrid_close_request($result); } if (count($output) == 1) { // If call is made for pagination, always return array if (isset($arrayIndexEndValue)) { return $output; } else { return $output[0]; } } return $output; }
/** * Fetch Field Names * * Generates an array of column names * * @access public * @return array */ function list_fields() { return cubrid_column_names($this->result_id); }
/** * @group php-822 */ public function testCubridColumnNames2() { if (OUTPUT_FUNCTION_NAME == true) { echo "\r\nRunning: " . __FUNCTION__ . " = "; } try { $this->sql = "create table test1 (id int, hobby set)"; cubrid_execute($this->con, $this->sql); $this->sql = "insert into test1 values(1, {'a', 'b', 'c'})"; cubrid_execute($this->con, $this->sql); $this->sql = "select * from test1 where id=1"; $this->req = cubrid_execute($this->con, $this->sql); $colnames = cubrid_column_names(NULL); $this->assertTrue(FALSE); } catch (Exception $e) { $this->assertTrue(TRUE); $this->req = null; $this->log = __FUNCTION__; self::writeErrorLog($e); $this->sql = "drop table test1"; cubrid_execute($this->con, $this->sql); } }