OdbcResultSet now uses the new resultset input

This commit is contained in:
Guillermo Dev
2018-10-16 00:09:57 +02:00
parent 9ab9f64ca4
commit f73e125008

View File

@@ -6,38 +6,18 @@ class OdbcResultSet implements \Iterator, \ArrayAccess
public $length; public $length;
private $results; private $results;
private $error; private $error = false;
private $num_fields; private $num_fields;
private $num_rows; private $num_rows;
private $cursor_index; private $cursor_index;
public function __construct($odbc_result) public function __construct($resultset)
{ {
if ($odbc_result === false) { $this->results = $resultset;
$this->error = odbc_errormsg(Connection::get()); $this->num_fields = is_array(current($resultset)) ? count(current($resultset)) : count($resultset);
} else { $this->num_rows = count($this->results);
try { $this->length = $this->num_rows;
$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->cursor_index = 0;
$this->length = count($this->results);
odbc_free_result($odbc_result);
}
} }
public function get_num_rows() public function get_num_rows()