Commits

Anonymous committed 0004f5d

Comments (0)

Files changed (1)

system/drivers/DB_odbc.php

 	 */
 	function _fetch_assoc()
 	{
-		return odbc_fetch_array($this->result_id);
+		if (function_exists('odbc_fetch_object'))
+		{
+			return odbc_fetch_array($this->result_id);
+		}
+		else
+		{
+			return $this->_odbc_fetch_array($this->result_id);
+		}
 	}
-	
+
 	// --------------------------------------------------------------------
 
 	/**
 	 */
 	function _fetch_object()
 	{
-		return odbc_fetch_object($this->result_id);
+		if (function_exists('odbc_fetch_object'))
+		{
+			return odbc_fetch_object($this->result_id);
+		}
+		else
+		{
+			return $this->_odbc_fetch_object($this->result_id);
+		}
 	}
-	
+
+
+	/**
+	 * Result - object
+	 *
+	 * subsititutes the odbc_fetch_object function when
+	 * not available (odbc_fetch_object requires unixODBC)
+	 *
+	 * @access	private
+	 * @return	object
+	 */
+
+	function _odbc_fetch_object(& $odbc_result) {
+		$rs = array();
+		$rs_obj = false;
+		if (odbc_fetch_into($odbc_result, $rs)) {
+			foreach ($rs as $k=>$v) {
+				$field_name= odbc_field_name($odbc_result, $k+1);
+				$rs_obj->$field_name = $v;
+			}
+		}
+		return $rs_obj;
+	}
+
+
+	/**
+	 * Result - array
+	 *
+	 * subsititutes the odbc_fetch_array function when
+	 * not available (odbc_fetch_array requires unixODBC)
+	 *
+	 * @access	private
+	 * @return	array
+	 */
+
+	function _odbc_fetch_array(& $odbc_result) {
+		$rs = array();
+		$rs_assoc = false;
+		if (odbc_fetch_into($odbc_result, $rs)) {
+			$rs_assoc=array();
+			foreach ($rs as $k=>$v) {
+				$field_name= odbc_field_name($odbc_result, $k+1);
+				$rs_assoc[$field_name] = $v;
+			}
+		}
+		return $rs_assoc;
+	}
+
 }
 
 ?>