ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
MDB2_Result_pgsql Class Reference
+ Inheritance diagram for MDB2_Result_pgsql:
+ Collaboration diagram for MDB2_Result_pgsql:

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...
 
 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 1052 of file pgsql.php.

Member Function Documentation

◆ _getColumnNames()

MDB2_Result_pgsql::_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 1137 of file pgsql.php.

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

1138  {
1139  $columns = array();
1140  $numcols = $this->numCols();
1141  if (PEAR::isError($numcols)) {
1142  return $numcols;
1143  }
1144  for ($column = 0; $column < $numcols; $column++) {
1145  $column_name = @pg_field_name($this->result, $column);
1146  $columns[$column_name] = $column;
1147  }
1148  if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
1149  $columns = array_change_key_case($columns, $this->db->options['field_case']);
1150  }
1151  return $columns;
1152  }
$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: pgsql.php:1164
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_pgsql::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 1065 of file pgsql.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, MDB2_PORTABILITY_RTRIM, and object.

1066  {
1067  if (!is_null($rownum)) {
1068  $seek = $this->seek($rownum);
1069  if (PEAR::isError($seek)) {
1070  return $seek;
1071  }
1072  }
1073  if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
1074  $fetchmode = $this->db->fetchmode;
1075  }
1076  if ($fetchmode & MDB2_FETCHMODE_ASSOC) {
1077  $row = @pg_fetch_array($this->result, null, PGSQL_ASSOC);
1078  if (is_array($row)
1079  && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
1080  ) {
1081  $row = array_change_key_case($row, $this->db->options['field_case']);
1082  }
1083  } else {
1084  $row = @pg_fetch_row($this->result);
1085  }
1086  if (!$row) {
1087  if ($this->result === false) {
1088  $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1089  'resultset has already been freed', __FUNCTION__);
1090  return $err;
1091  }
1092  $null = null;
1093  return $null;
1094  }
1095  $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL;
1096  $rtrim = false;
1097  if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) {
1098  if (empty($this->types)) {
1099  $mode += MDB2_PORTABILITY_RTRIM;
1100  } else {
1101  $rtrim = true;
1102  }
1103  }
1104  if ($mode) {
1105  $this->db->_fixResultArrayValues($row, $mode);
1106  }
1107  if (!empty($this->types)) {
1108  $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim);
1109  }
1110  if (!empty($this->values)) {
1111  $this->_assignBindColumns($row);
1112  }
1113  if ($fetchmode === MDB2_FETCHMODE_OBJECT) {
1114  $object_class = $this->db->options['fetch_class'];
1115  if ($object_class == 'stdClass') {
1116  $row = (object) $row;
1117  } else {
1118  $row = new $object_class($row);
1119  }
1120  }
1121  ++$this->rownum;
1122  return $row;
1123  }
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:3812
const MDB2_FETCHMODE_OBJECT
Column data as object properties.
Definition: MDB2.php:139
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:92
const MDB2_PORTABILITY_RTRIM
Portability: right trim the data output by query*() and fetch*().
Definition: MDB2.php:169
seek($rownum=0)
Seek to a specific row in a result set.
Definition: MDB2.php:3458
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_pgsql::free ( )

Free the internal resources associated with result.

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

Definition at line 1211 of file pgsql.php.

References MDB2_OK.

1212  {
1213  if (is_resource($this->result) && $this->db->connection) {
1214  $free = @pg_free_result($this->result);
1215  if ($free === false) {
1216  return $this->db->raiseError(null, null, null,
1217  'Could not free result', __FUNCTION__);
1218  }
1219  }
1220  $this->result = false;
1221  return MDB2_OK;
1222  }
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

◆ nextResult()

MDB2_Result_pgsql::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 1189 of file pgsql.php.

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

1190  {
1191  $connection = $this->db->getConnection();
1192  if (PEAR::isError($connection)) {
1193  return $connection;
1194  }
1195 
1196  if (!($this->result = @pg_get_result($connection))) {
1197  return false;
1198  }
1199  return MDB2_OK;
1200  }
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
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ numCols()

MDB2_Result_pgsql::numCols ( )

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

public

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

Definition at line 1164 of file pgsql.php.

References $cols, and MDB2_ERROR_NEED_MORE_DATA.

1165  {
1166  $cols = @pg_num_fields($this->result);
1167  if (is_null($cols)) {
1168  if ($this->result === false) {
1169  return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
1170  'resultset has already been freed', __FUNCTION__);
1171  } elseif (is_null($this->result)) {
1172  return count($this->types);
1173  }
1174  return $this->db->raiseError(null, null, null,
1175  'Could not get column count', __FUNCTION__);
1176  }
1177  return $cols;
1178  }
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:92
$cols
Definition: xhr_table.php:11

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