ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 1147 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. private

Definition at line 1225 of file mysqli.php.

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

1226  {
1227  $columns = array();
1228  $numcols = $this->numCols();
1229  if (PEAR::isError($numcols)) {
1230  return $numcols;
1231  }
1232  for ($column = 0; $column < $numcols; $column++) {
1233  $column_info = @mysqli_fetch_field_direct($this->result, $column);
1234  $columns[$column_info->name] = $column;
1235  }
1236  if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
1237  $columns = array_change_key_case($columns, $this->db->options['field_case']);
1238  }
1239  return $columns;
1240  }
numCols()
Count the number of columns returned by the DBMS in a query result.
Definition: mysqli.php:1252
if(! $in) $columns
Definition: Utf8Test.php:46
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
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ 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 public

Definition at line 1160 of file mysqli.php.

References MDB2_Driver_Common\$fetchmode, $row, PEAR\isError(), MDB2_ERROR_NEED_MORE_DATA, MDB2_FETCHMODE_ASSOC, MDB2_FETCHMODE_DEFAULT, MDB2_FETCHMODE_OBJECT, MDB2_PORTABILITY_EMPTY_TO_NULL, and MDB2_PORTABILITY_FIX_CASE.

1161  {
1162  if (!is_null($rownum)) {
1163  $seek = $this->seek($rownum);
1164  if (PEAR::isError($seek)) {
1165  return $seek;
1166  }
1167  }
1168  if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
1169  $fetchmode = $this->db->fetchmode;
1170  }
1171  if ($fetchmode & MDB2_FETCHMODE_ASSOC) {
1172  $row = @mysqli_fetch_assoc($this->result);
1173  if (is_array($row)
1174  && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
1175  ) {
1176  $row = array_change_key_case($row, $this->db->options['field_case']);
1177  }
1178  } else {
1179  $row = @mysqli_fetch_row($this->result);
1180  }
1181 
1182  if (!$row) {
1183  if ($this->result === false) {
1184  $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1185  'resultset has already been freed', __FUNCTION__);
1186  return $err;
1187  }
1188  $null = null;
1189  return $null;
1190  }
1191  $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL;
1192  if ($mode) {
1193  $this->db->_fixResultArrayValues($row, $mode);
1194  }
1195  if (!empty($this->types)) {
1196  $row = $this->db->datatype->convertResultRow($this->types, $row, false);
1197  }
1198  if (!empty($this->values)) {
1199  $this->_assignBindColumns($row);
1200  }
1201  if ($fetchmode === MDB2_FETCHMODE_OBJECT) {
1202  $object_class = $this->db->options['fetch_class'];
1203  if ($object_class == 'stdClass') {
1204  $row = (object) $row;
1205  } else {
1206  $row = &new $object_class($row);
1207  }
1208  }
1209  ++$this->rownum;
1210  return $row;
1211  }
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:129
const MDB2_FETCHMODE_DEFAULT
This is a special constant that tells MDB2 the user hasn&#39;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
_assignBindColumns($row)
Bind a variable to a value in the result row.
Definition: MDB2.php:3786
const MDB2_FETCHMODE_OBJECT
Column data as object properties.
Definition: MDB2.php:134
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:87
seek($rownum=0)
Seek to a specific row in a result set.
Definition: MDB2.php:3432
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
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ 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 public

Definition at line 1305 of file mysqli.php.

References MDB2_OK.

1306  {
1307  if (is_object($this->result) && $this->db->connection) {
1308  $free = @mysqli_free_result($this->result);
1309  if ($free === false) {
1310  return $this->db->raiseError(null, null, null,
1311  'Could not free result', __FUNCTION__);
1312  }
1313  }
1314  $this->result = false;
1315  return MDB2_OK;
1316  }
const MDB2_OK
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
Definition: MDB2.php:67

◆ 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 public

Definition at line 1277 of file mysqli.php.

References MDB2_Driver_Common\$connection, PEAR\isError(), and MDB2_OK.

1278  {
1279  $connection = $this->db->getConnection();
1280  if (PEAR::isError($connection)) {
1281  return $connection;
1282  }
1283 
1284  if (!@mysqli_more_results($connection)) {
1285  return false;
1286  }
1287  if (!@mysqli_next_result($connection)) {
1288  return false;
1289  }
1290  if (!($this->result = @mysqli_use_result($connection))) {
1291  return false;
1292  }
1293  return MDB2_OK;
1294  }
const MDB2_OK
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
Definition: MDB2.php:67
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ 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 public

Definition at line 1252 of file mysqli.php.

References MDB2_ERROR_NEED_MORE_DATA.

1253  {
1254  $cols = @mysqli_num_fields($this->result);
1255  if (is_null($cols)) {
1256  if ($this->result === false) {
1257  return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1258  'resultset has already been freed', __FUNCTION__);
1259  } elseif (is_null($this->result)) {
1260  return count($this->types);
1261  }
1262  return $this->db->raiseError(null, null, null,
1263  'Could not get column count', __FUNCTION__);
1264  }
1265  return $cols;
1266  }
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:87

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