summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/database/drivers/odbc/odbc_result.php38
-rw-r--r--user_guide_src/source/changelog.rst2
2 files changed, 20 insertions, 20 deletions
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index ba660856e..bfd6949eb 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -54,10 +54,9 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @odbc_num_fields($this->result_id);
}
@@ -69,15 +68,19 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ $num_fields = $this->num_fields();
+
+ if ($num_fields > 0)
{
- $field_names[] = odbc_field_name($this->result_id, $i);
+ for ($i = 1; $i <= $num_fields; $i++)
+ {
+ $field_names[] = odbc_field_name($this->result_id, $i);
+ }
}
return $field_names;
@@ -90,22 +93,19 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $odbc_index = 1, $c = $this->num_fields(); $i < $c; $i++, $odbc_index++)
{
- $F = new stdClass();
- $F->name = odbc_field_name($this->result_id, $i);
- $F->type = odbc_field_type($this->result_id, $i);
- $F->max_length = odbc_field_len($this->result_id, $i);
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = odbc_field_name($this->result_id, $odbc_index);
+ $retval[$i]->type = odbc_field_type($this->result_id, $odbc_index);
+ $retval[$i]->max_length = odbc_field_len($this->result_id, $odbc_index);
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -237,4 +237,4 @@ class CI_DB_odbc_result extends CI_DB_result {
/* End of file odbc_result.php */
-/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_result.php */
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index e8bbf7d14..bd9776ce1 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -113,7 +113,7 @@ Bug fixes for 3.0
- Fixed a bug (#1070) - CI_DB_driver::initialize() didn't set a character set if a database is not selected.
- Fixed a bug (#177) - CI_Form_validation::set_value() didn't set the default value if POST data is NULL.
- Fixed a bug (#68, #414) - Oracle's escape_str() didn't properly escape LIKE wild characters.
-
+- Fixed a bug (#81) - ODBC's list_fields() and field_data() methods skipped the first column due to odbc_field_*() functions' index starting at 1 instead of 0.
Version 2.1.1
=============