OdbcResultSet now uses the new resultset input
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user