Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes for fetch results.

  • Loading branch information...
commit a7a86e42a310bfe4371eb7229965aaf9c79fbb7e 1 parent 83b81ff
@jrbasso jrbasso authored
Showing with 16 additions and 17 deletions.
  1. +16 −17 lib/Cake/Model/Datasource/Database/Mssql.php
View
33 lib/Cake/Model/Datasource/Database/Mssql.php
@@ -406,19 +406,18 @@ function column($real) {
}
/**
- * Enter description here...
+ * Builds a map of the columns contained in a result
*
- * @param unknown_type $results
+ * @param PDOStatement $results
*/
- function resultSet(&$results) {
- $this->results =& $results;
+ function resultSet($results) {
$this->map = array();
- $numFields = mssql_num_fields($results);
+ $numFields = $results->columnCount();
$index = 0;
$j = 0;
- while ($j < $numFields) {
- $column = mssql_field_name($results, $j);
+ while ($numFields-- > 0) {
+ $column = $results->getColumnMeta($index);
if (strpos($column, '__')) {
if (isset($this->__fieldMappings[$column]) && strpos($this->__fieldMappings[$column], '.')) {
@@ -536,22 +535,22 @@ function read($model, $queryData = array(), $recursive = null) {
/**
* Fetches the next row from the current result set
*
- * @return unknown
+ * @return mixed
*/
function fetchResult() {
- if ($row = mssql_fetch_row($this->results)) {
+ if ($row = $this->_result->fetch()) {
$resultRow = array();
- $i = 0;
-
- foreach ($row as $index => $field) {
- list($table, $column) = $this->map[$index];
- $resultRow[$table][$column] = $row[$index];
- $i++;
+ foreach ($this->map as $col => $meta) {
+ list($table, $column, $type) = $meta;
+ $resultRow[$table][$column] = $row[$col];
+ if ($type === 'boolean' && !is_null($row[$col])) {
+ $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
+ }
}
return $resultRow;
- } else {
- return false;
}
+ $this->_result->closeCursor();
+ return false;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.