From f73e12500847791d1168ee2793dd0ca92dae6ce8 Mon Sep 17 00:00:00 2001 From: Guillermo Dev Date: Tue, 16 Oct 2018 00:09:57 +0200 Subject: [PATCH] OdbcResultSet now uses the new resultset input --- src/Db/OdbcResultset.php | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/Db/OdbcResultset.php b/src/Db/OdbcResultset.php index c7324b8..cdd834b 100644 --- a/src/Db/OdbcResultset.php +++ b/src/Db/OdbcResultset.php @@ -6,38 +6,18 @@ class OdbcResultSet implements \Iterator, \ArrayAccess public $length; private $results; - private $error; + private $error = false; private $num_fields; private $num_rows; private $cursor_index; - public function __construct($odbc_result) + public function __construct($resultset) { - if ($odbc_result === false) { - $this->error = odbc_errormsg(Connection::get()); - } else { - try { - $this->results = array(); - $this->num_fields = odbc_num_fields($odbc_result); - $this->num_rows = odbc_num_rows($odbc_result); - - if ($this->num_fields > 0) { - while ($row = odbc_fetch_row($odbc_result)) { - $data = array(); - for ($i = 1; $i <= $this->num_fields; ++$i) { - $data[odbc_field_name($odbc_result, $i)] = utf8_encode(odbc_result($odbc_result, $i)); - } - $this->results[] = $data; - } - }; - } catch (\Exception $e) { - print($e->getMessage()); - } - - $this->cursor_index = 0; - $this->length = count($this->results); - odbc_free_result($odbc_result); - } + $this->results = $resultset; + $this->num_fields = is_array(current($resultset)) ? count(current($resultset)) : count($resultset); + $this->num_rows = count($this->results); + $this->length = $this->num_rows; + $this->cursor_index = 0; } public function get_num_rows()