ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
MDB2_Result_mysqli Class Reference
+ Inheritance diagram for MDB2_Result_mysqli:
+ Collaboration diagram for MDB2_Result_mysqli:

Public Member Functions

fetchRow ($fetchmode=MDB2_FETCHMODE_DEFAULT, $rownum=null)
 Fetch a row and insert the data into an existing array. More...
 
 _getColumnNames ()
 Retrieve the names of columns returned by the DBMS in a query result. More...
 
 numCols ()
 Count the number of columns returned by the DBMS in a query result. More...
 
 nextResult ()
 Move the internal result pointer to the next available result. More...
 
 free ()
 Free the internal resources associated with result. More...
 
- Public Member Functions inherited from MDB2_Result_Common
 __construct (&$db, &$result, $limit=0, $offset=0)
 Constructor. More...
 
 MDB2_Result_Common (&$db, &$result, $limit=0, $offset=0)
 PHP 4 Constructor. More...
 
 setResultTypes ($types)
 Define the list of types to be associated with the columns of a given result set. More...
 
 seek ($rownum=0)
 Seek to a specific row in a result set. More...
 
fetchRow ($fetchmode=MDB2_FETCHMODE_DEFAULT, $rownum=null)
 Fetch and return a row of data. More...
 
 fetchOne ($colnum=0, $rownum=null)
 fetch single column from the next row from a result set More...
 
 fetchCol ($colnum=0)
 Fetch and return a column from the current row pointer position. More...
 
 fetchAll ($fetchmode=MDB2_FETCHMODE_DEFAULT, $rekey=false, $force_array=false, $group=false)
 Fetch and return all rows from the current row pointer position. More...
 
 rowCount ()
 Returns the actual row number that was last fetched (count from 0) More...
 
 numRows ()
 Returns the number of rows in a result object. More...
 
 nextResult ()
 Move the internal result pointer to the next available result. More...
 
 getColumnNames ($flip=false)
 Retrieve the names of columns returned by the DBMS in a query result or from the cache. More...
 
 _getColumnNames ()
 Retrieve the names of columns returned by the DBMS in a query result. More...
 
 numCols ()
 Count the number of columns returned by the DBMS in a query result. More...
 
 getResource ()
 return the resource associated with the result object More...
 
 bindColumn ($column, &$value, $type=null)
 Set bind variable to a column. More...
 
 _assignBindColumns ($row)
 Bind a variable to a value in the result row. More...
 
 free ()
 Free the internal resources associated with result. More...
 

Additional Inherited Members

- Data Fields inherited from MDB2_Result_Common
 $db
 
 $result
 
 $rownum = -1
 
 $types = array()
 
 $values = array()
 
 $offset
 
 $offset_count = 0
 
 $limit
 
 $column_names
 

Detailed Description

Definition at line 1164 of file mysqli.php.

Member Function Documentation

◆ _getColumnNames()

MDB2_Result_mysqli::_getColumnNames ( )

Retrieve the names of columns returned by the DBMS in a query result.

Returns
mixed Array variable that holds the names of columns as keys or an MDB2 error on failure. Some DBMS may not return any columns when the result set does not contain any rows. @access private

Reimplemented from MDB2_Result_Common.

Definition at line 1242 of file mysqli.php.

1243 {
1244 $columns = array();
1245 $numcols = $this->numCols();
1246 if (PEAR::isError($numcols)) {
1247 return $numcols;
1248 }
1249 for ($column = 0; $column < $numcols; $column++) {
1250 $column_info = @mysqli_fetch_field_direct($this->result, $column);
1251 $columns[$column_info->name] = $column;
1252 }
1253 if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
1254 $columns = array_change_key_case($columns, $this->db->options['field_case']);
1255 }
1256 return $columns;
1257 }
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:158
if(! $in) $columns
Definition: Utf8Test.php:46
numCols()
Count the number of columns returned by the DBMS in a query result.
Definition: mysqli.php:1269
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279

References $columns, PEAR\isError(), MDB2_PORTABILITY_FIX_CASE, and numCols().

+ Here is the call graph for this function:

◆ fetchRow()

& MDB2_Result_mysqli::fetchRow (   $fetchmode = MDB2_FETCHMODE_DEFAULT,
  $rownum = null 
)

Fetch a row and insert the data into an existing array.

Parameters
int$fetchmodehow the array data should be indexed
int$rownumnumber of the row where the data can be found
Returns
int data array on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Result_Common.

Definition at line 1177 of file mysqli.php.

1178 {
1179 if (!is_null($rownum)) {
1180 $seek = $this->seek($rownum);
1181 if (PEAR::isError($seek)) {
1182 return $seek;
1183 }
1184 }
1185 if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
1186 $fetchmode = $this->db->fetchmode;
1187 }
1188 if ($fetchmode & MDB2_FETCHMODE_ASSOC) {
1189 $row = @mysqli_fetch_assoc($this->result);
1190 if (is_array($row)
1191 && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
1192 ) {
1193 $row = array_change_key_case($row, $this->db->options['field_case']);
1194 }
1195 } else {
1196 $row = @mysqli_fetch_row($this->result);
1197 }
1198
1199 if (!$row) {
1200 if ($this->result === false) {
1201 $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1202 'resultset has already been freed', __FUNCTION__);
1203 return $err;
1204 }
1205 $null = null;
1206 return $null;
1207 }
1208 $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL;
1209 if ($mode) {
1210 $this->db->_fixResultArrayValues($row, $mode);
1211 }
1212 if (!empty($this->types)) {
1213 $row = $this->db->datatype->convertResultRow($this->types, $row, false);
1214 }
1215 if (!empty($this->values)) {
1216 $this->_assignBindColumns($row);
1217 }
1218 if ($fetchmode === MDB2_FETCHMODE_OBJECT) {
1219 $object_class = $this->db->options['fetch_class'];
1220 if ($object_class == 'stdClass') {
1221 $row = (object) $row;
1222 } else {
1223 $row = &new $object_class($row);
1224 }
1225 }
1226 ++$this->rownum;
1227 return $row;
1228 }
const MDB2_FETCHMODE_DEFAULT
This is a special constant that tells MDB2 the user hasn't specified any particular get mode,...
Definition: MDB2.php:119
const MDB2_PORTABILITY_EMPTY_TO_NULL
Portability: convert empty values to null strings in data output by query*() and fetch*().
Definition: MDB2.php:198
const MDB2_FETCHMODE_OBJECT
Column data as object properties.
Definition: MDB2.php:134
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:87
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:129
_assignBindColumns($row)
Bind a variable to a value in the result row.
Definition: MDB2.php:3786
seek($rownum=0)
Seek to a specific row in a result set.
Definition: MDB2.php:3432

References $row, MDB2_Result_Common\$rownum, MDB2_Result_Common\_assignBindColumns(), PEAR\isError(), MDB2_ERROR_NEED_MORE_DATA, MDB2_FETCHMODE_ASSOC, MDB2_FETCHMODE_DEFAULT, MDB2_FETCHMODE_OBJECT, MDB2_PORTABILITY_EMPTY_TO_NULL, MDB2_PORTABILITY_FIX_CASE, and MDB2_Result_Common\seek().

+ Here is the call graph for this function:

◆ free()

MDB2_Result_mysqli::free ( )

Free the internal resources associated with result.

Returns
boolean true on success, false if result is invalid @access public

Reimplemented from MDB2_Result_Common.

Definition at line 1322 of file mysqli.php.

1323 {
1324 if (is_object($this->result) && $this->db->connection) {
1325 $free = @mysqli_free_result($this->result);
1326 if ($free === false) {
1327 return $this->db->raiseError(null, null, null,
1328 'Could not free result', __FUNCTION__);
1329 }
1330 }
1331 $this->result = false;
1332 return MDB2_OK;
1333 }
const MDB2_OK
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
Definition: MDB2.php:67

References MDB2_OK.

◆ nextResult()

MDB2_Result_mysqli::nextResult ( )

Move the internal result pointer to the next available result.

Returns
true on success, false if there is no more result set or an error object on failure @access public

Reimplemented from MDB2_Result_Common.

Reimplemented in MDB2_BufferedResult_mysqli.

Definition at line 1294 of file mysqli.php.

1295 {
1296 $connection = $this->db->getConnection();
1297 if (PEAR::isError($connection)) {
1298 return $connection;
1299 }
1300
1301 if (!@mysqli_more_results($connection)) {
1302 return false;
1303 }
1304 if (!@mysqli_next_result($connection)) {
1305 return false;
1306 }
1307 if (!($this->result = @mysqli_use_result($connection))) {
1308 return false;
1309 }
1310 return MDB2_OK;
1311 }

References PEAR\isError(), and MDB2_OK.

+ Here is the call graph for this function:

◆ numCols()

MDB2_Result_mysqli::numCols ( )

Count the number of columns returned by the DBMS in a query result.

Returns
mixed integer value with the number of columns, a MDB2 error on failure @access public

Reimplemented from MDB2_Result_Common.

Definition at line 1269 of file mysqli.php.

1270 {
1271 $cols = @mysqli_num_fields($this->result);
1272 if (is_null($cols)) {
1273 if ($this->result === false) {
1274 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1275 'resultset has already been freed', __FUNCTION__);
1276 } elseif (is_null($this->result)) {
1277 return count($this->types);
1278 }
1279 return $this->db->raiseError(null, null, null,
1280 'Could not get column count', __FUNCTION__);
1281 }
1282 return $cols;
1283 }

References MDB2_ERROR_NEED_MORE_DATA.

Referenced by _getColumnNames().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: