ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
MDB2_Result_mysql Class Reference
+ Inheritance diagram for MDB2_Result_mysql:
+ Collaboration diagram for MDB2_Result_mysql:

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...
 
 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...
 
 fetch ($fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
 
 fetchObject ()
 
 fetchAssoc ()
 
 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...
 
 execute ($a_data=null)
 
- Public Member Functions inherited from ilDBStatement
 fetchRow ($fetch_mode)
 

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 1133 of file mysql.php.

Member Function Documentation

◆ _getColumnNames()

MDB2_Result_mysql::_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 1211 of file mysql.php.

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

1212  {
1213  $columns = array();
1214  $numcols = $this->numCols();
1215  if (PEAR::isError($numcols)) {
1216  return $numcols;
1217  }
1218  for ($column = 0; $column < $numcols; $column++) {
1219  $column_name = @mysql_field_name($this->result, $column);
1220  $columns[$column_name] = $column;
1221  }
1222  if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
1223  $columns = array_change_key_case($columns, $this->db->options['field_case']);
1224  }
1225  return $columns;
1226  }
$column
Definition: 39dropdown.php:62
Create styles array
The data for the language used.
numCols()
Count the number of columns returned by the DBMS in a query result.
Definition: mysql.php:1238
if(! $in) $columns
Definition: Utf8Test.php:45
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:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ fetchRow()

& MDB2_Result_mysql::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 1146 of file mysql.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, MDB2_PORTABILITY_FIX_CASE, and object.

1147  {
1148  if (!is_null($rownum)) {
1149  $seek = $this->seek($rownum);
1150  if (PEAR::isError($seek)) {
1151  return $seek;
1152  }
1153  }
1154  if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
1155  $fetchmode = $this->db->fetchmode;
1156  }
1157  if ($fetchmode & MDB2_FETCHMODE_ASSOC) {
1158  $row = @mysql_fetch_assoc($this->result);
1159  if (is_array($row)
1160  && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
1161  ) {
1162  $row = array_change_key_case($row, $this->db->options['field_case']);
1163  }
1164  } else {
1165  $row = @mysql_fetch_row($this->result);
1166  }
1167 
1168  if (!$row) {
1169  if ($this->result === false) {
1170  $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1171  'resultset has already been freed', __FUNCTION__);
1172  return $err;
1173  }
1174  $null = null;
1175  return $null;
1176  }
1177  $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL;
1178  if ($mode) {
1179  $this->db->_fixResultArrayValues($row, $mode);
1180  }
1181  if (!empty($this->types)) {
1182  $row = $this->db->datatype->convertResultRow($this->types, $row, false);
1183  }
1184  if (!empty($this->values)) {
1185  $this->_assignBindColumns($row);
1186  }
1187  if ($fetchmode === MDB2_FETCHMODE_OBJECT) {
1188  $object_class = $this->db->options['fetch_class'];
1189  if ($object_class == 'stdClass') {
1190  $row = (object) $row;
1191  } else {
1192  $row = new $object_class($row);
1193  }
1194  }
1195  ++$this->rownum;
1196  return $row;
1197  }
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:134
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:124
const MDB2_PORTABILITY_EMPTY_TO_NULL
Portability: convert empty values to null strings in data output by query*() and fetch*().
Definition: MDB2.php:203
_assignBindColumns($row)
Bind a variable to a value in the result row.
Definition: MDB2.php:3806
const MDB2_FETCHMODE_OBJECT
Column data as object properties.
Definition: MDB2.php:139
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:92
seek($rownum=0)
Seek to a specific row in a result set.
Definition: MDB2.php:3452
Create new PHPExcel object
obj_idprivate
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:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ free()

MDB2_Result_mysql::free ( )

Free the internal resources associated with result.

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

Definition at line 1263 of file mysql.php.

References MDB2_OK.

1264  {
1265  if (is_resource($this->result) && $this->db->connection) {
1266  $free = @mysql_free_result($this->result);
1267  if ($free === false) {
1268  return $this->db->raiseError(null, null, null,
1269  'Could not free result', __FUNCTION__);
1270  }
1271  }
1272  $this->result = false;
1273  return MDB2_OK;
1274  }
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
Definition: MDB2.php:72

◆ numCols()

MDB2_Result_mysql::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 1238 of file mysql.php.

References MDB2_ERROR_NEED_MORE_DATA.

1239  {
1240  $cols = @mysql_num_fields($this->result);
1241  if (is_null($cols)) {
1242  if ($this->result === false) {
1243  return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1244  'resultset has already been freed', __FUNCTION__);
1245  } elseif (is_null($this->result)) {
1246  return count($this->types);
1247  }
1248  return $this->db->raiseError(null, null, null,
1249  'Could not get column count', __FUNCTION__);
1250  }
1251  return $cols;
1252  }
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:92

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