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

Public Member Functions

_execute ($result_class=true, $result_wrap_class=false)
 Execute a prepared query statement helper method. More...
 
 free ()
 Release resources allocated for the specified prepared query. More...
 
- Public Member Functions inherited from MDB2_Statement_Common
 __construct (&$db, &$statement, $positions, $query, $types, $result_types, $is_manip=false, $limit=null, $offset=null)
 Constructor. More...
 
 MDB2_Statement_Common (&$db, &$statement, $positions, $query, $types, $result_types, $is_manip=false, $limit=null, $offset=null)
 PHP 4 Constructor. More...
 
 bindValue ($parameter, $value, $type=null)
 Set the value of a parameter of a prepared query. More...
 
 bindValueArray ($values, $types=null)
 Set the values of multiple a parameter of a prepared query in bulk. More...
 
 bindParam ($parameter, &$value, $type=null)
 Bind a variable to a parameter of a prepared query. More...
 
 bindParamArray (&$values, $types=null)
 Bind the variables of multiple a parameter of a prepared query in bulk. More...
 
execute ($values=null, $result_class=true, $result_wrap_class=false)
 Execute a prepared query statement. More...
 
_execute ($result_class=true, $result_wrap_class=false)
 Execute a prepared query statement helper method. More...
 
 free ()
 Release resources allocated for the specified prepared query. More...
 

Additional Inherited Members

- Data Fields inherited from MDB2_Statement_Common
 $db
 
 $statement
 
 $query
 
 $result_types
 
 $types
 
 $values = array()
 
 $limit
 
 $offset
 
 $is_manip
 

Detailed Description

Definition at line 1310 of file pgsql.php.

Member Function Documentation

◆ _execute()

& MDB2_Statement_pgsql::_execute (   $result_class = true,
  $result_wrap_class = false 
)

Execute a prepared query statement helper method.

Parameters
mixed$result_classstring which specifies which result class to use
mixed$result_wrap_classstring which specifies which class to wrap results in
Returns
mixed a result handle or MDB2_OK on success, a MDB2 error on failure private

Definition at line 1322 of file pgsql.php.

References MDB2_Driver_Common\$connection, $data, $query, $result, $type, array, PEAR\isError(), MDB2_ERROR_NOT_FOUND, and MDB2_Driver_Common\query().

1323  {
1324  if (is_null($this->statement)) {
1325  $result =& parent::_execute($result_class, $result_wrap_class);
1326  return $result;
1327  }
1328  $this->db->last_query = $this->query;
1329  $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values));
1330  if ($this->db->getOption('disable_query')) {
1331  $result = $this->is_manip ? 0 : null;
1332  return $result;
1333  }
1334 
1335  $connection = $this->db->getConnection();
1336  if (PEAR::isError($connection)) {
1337  return $connection;
1338  }
1339 
1340  $query = false;
1341  $parameters = array();
1342  // todo: disabled until pg_execute() bytea issues are cleared up
1343  if (true || !function_exists('pg_execute')) {
1344  $query = 'EXECUTE '.$this->statement;
1345  }
1346  if (!empty($this->positions)) {
1347  foreach ($this->positions as $parameter) {
1348  if (!array_key_exists($parameter, $this->values)) {
1349  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
1350  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
1351  }
1352  $value = $this->values[$parameter];
1353  $type = array_key_exists($parameter, $this->types) ? $this->types[$parameter] : null;
1354  if (is_resource($value) || $type == 'clob' || $type == 'blob') {
1355  if (!is_resource($value) && preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
1356  if ($match[1] == 'file://') {
1357  $value = $match[2];
1358  }
1359  $value = @fopen($value, 'r');
1360  $close = true;
1361  }
1362  if (is_resource($value)) {
1363  $data = '';
1364  while (!@feof($value)) {
1365  $data.= @fread($value, $this->db->options['lob_buffer_length']);
1366  }
1367  if ($close) {
1368  @fclose($value);
1369  }
1370  $value = $data;
1371  }
1372  }
1373  $parameters[] = $this->db->quote($value, $type, $query);
1374  }
1375  if ($query) {
1376  $query.= ' ('.implode(', ', $parameters).')';
1377  }
1378  }
1379 
1380  if (!$query) {
1381  $result = @pg_execute($connection, $this->statement, $parameters);
1382  if (!$result) {
1383  $err =& $this->db->raiseError(null, null, null,
1384  'Unable to execute statement', __FUNCTION__);
1385  return $err;
1386  }
1387  } else {
1388  $result = $this->db->_doQuery($query, $this->is_manip, $connection);
1389  if (PEAR::isError($result)) {
1390  return $result;
1391  }
1392  }
1393 
1394  if ($this->is_manip) {
1395  $affected_rows = $this->db->_affectedRows($connection, $result);
1396  return $affected_rows;
1397  }
1398 
1399  $result =& $this->db->_wrapResult($result, $this->result_types,
1400  $result_class, $result_wrap_class, $this->limit, $this->offset);
1401  $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result));
1402  return $result;
1403  }
$result
$type
const MDB2_ERROR_NOT_FOUND
Definition: MDB2.php:76
Create styles array
The data for the language used.
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_Statement_pgsql::free ( )

Release resources allocated for the specified prepared query.

Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 1414 of file pgsql.php.

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

1415  {
1416  if (is_null($this->positions)) {
1417  return $this->db->raiseError(MDB2_ERROR, null, null,
1418  'Prepared statement has already been freed', __FUNCTION__);
1419  }
1420  $result = MDB2_OK;
1421 
1422  if (!is_null($this->statement)) {
1423  $connection = $this->db->getConnection();
1424  if (PEAR::isError($connection)) {
1425  return $connection;
1426  }
1427  $query = 'DEALLOCATE PREPARE '.$this->statement;
1428  $result = $this->db->_doQuery($query, true, $connection);
1429  }
1430 
1431  parent::free();
1432  return $result;
1433  }
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
$result
const MDB2_ERROR
Definition: MDB2.php:73
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

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