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

Public Member Functions

 __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...
 

Data Fields

 $db
 
 $statement
 
 $query
 
 $result_types
 
 $types
 
 $values = array()
 
 $limit
 
 $offset
 
 $is_manip
 

Detailed Description

Definition at line 3900 of file MDB2.php.

Constructor & Destructor Documentation

◆ __construct()

MDB2_Statement_Common::__construct ( $db,
$statement,
  $positions,
  $query,
  $types,
  $result_types,
  $is_manip = false,
  $limit = null,
  $offset = null 
)

Constructor.

Definition at line 3920 of file MDB2.php.

References $query, and array.

3921  {
3922  $this->db =& $db;
3923  $this->statement =& $statement;
3924  $this->positions = $positions;
3925  $this->query = $query;
3926  $this->types = (array)$types;
3927  $this->result_types = (array)$result_types;
3928  $this->limit = $limit;
3929  $this->is_manip = $is_manip;
3930  $this->offset = $offset;
3931  }
Create styles array
The data for the language used.

Member Function Documentation

◆ _execute()

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

Execute a prepared query statement helper method.

Parameters
mixedspecifies which result class to use
mixedspecifies which class to wrap results in
Returns
mixed MDB2_Result or integer on success, a MDB2 error on failure

private

Definition at line 4114 of file MDB2.php.

References $query, $result, PEAR\isError(), and MDB2_ERROR_NOT_FOUND.

4115  {
4116  $this->last_query = $this->query;
4117  $query = '';
4118  $last_position = 0;
4119  foreach ($this->positions as $current_position => $parameter) {
4120  if (!array_key_exists($parameter, $this->values)) {
4121  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
4122  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4123  }
4124  $value = $this->values[$parameter];
4125  $query.= substr($this->query, $last_position, $current_position - $last_position);
4126  if (!isset($value)) {
4127  $value_quoted = 'NULL';
4128  } else {
4129  $type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
4130  $value_quoted = $this->db->quote($value, $type);
4131  if (PEAR::isError($value_quoted)) {
4132  return $value_quoted;
4133  }
4134  }
4135  $query.= $value_quoted;
4136  $last_position = $current_position + 1;
4137  }
4138  $query.= substr($this->query, $last_position);
4139 
4140  $this->db->offset = $this->offset;
4141  $this->db->limit = $this->limit;
4142  if ($this->is_manip) {
4143  $result = $this->db->exec($query);
4144  } else {
4145  $result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
4146  }
4147  return $result;
4148  }
$result
const MDB2_ERROR_NOT_FOUND
Definition: MDB2.php:76
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ bindParam()

MDB2_Statement_Common::bindParam (   $parameter,
$value,
  $type = null 
)

Bind a variable to a parameter of a prepared query.

Parameters
intthe order number of the parameter in the query statement. The order number of the first parameter is 1.
mixedvariable that is meant to be bound to specified parameter. The type of the value depends on the $type argument.
stringspecifies the type of the field
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Definition at line 4021 of file MDB2.php.

References MDB2_ERROR_NOT_FOUND, and MDB2_OK.

4022  {
4023  if (!is_numeric($parameter)) {
4024  $parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
4025  }
4026  if (!in_array($parameter, $this->positions)) {
4027  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
4028  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4029  }
4030  $this->values[$parameter] =& $value;
4031  if (!is_null($type)) {
4032  $this->types[$parameter] = $type;
4033  }
4034  return MDB2_OK;
4035  }
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
const MDB2_ERROR_NOT_FOUND
Definition: MDB2.php:76

◆ bindParamArray()

MDB2_Statement_Common::bindParamArray ( $values,
  $types = null 
)

Bind the variables of multiple a parameter of a prepared query in bulk.

Parameters
arrayspecifies all necessary information for bindParam() the array elements must use keys corresponding to the number of the position of the parameter.
arrayspecifies the types of the fields
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

See also
bindParam()

Definition at line 4053 of file MDB2.php.

References PEAR\isError(), and MDB2_OK.

4054  {
4055  $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4056  $parameters = array_keys($values);
4057  foreach ($parameters as $key => $parameter) {
4058  $err = $this->bindParam($parameter, $values[$parameter], $types[$key]);
4059  if (PEAR::isError($err)) {
4060  return $err;
4061  }
4062  }
4063  return MDB2_OK;
4064  }
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
bindParam($parameter, &$value, $type=null)
Bind a variable to a parameter of a prepared query.
Definition: MDB2.php:4021
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ bindValue()

MDB2_Statement_Common::bindValue (   $parameter,
  $value,
  $type = null 
)

Set the value of a parameter of a prepared query.

Parameters
intthe order number of the parameter in the query statement. The order number of the first parameter is 1.
mixedvalue that is meant to be assigned to specified parameter. The type of the value depends on the $type argument.
stringspecifies the type of the field
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Definition at line 3960 of file MDB2.php.

References MDB2_ERROR_NOT_FOUND, and MDB2_OK.

3961  {
3962  if (!is_numeric($parameter)) {
3963  $parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
3964  }
3965  if (!in_array($parameter, $this->positions)) {
3966  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
3967  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
3968  }
3969  $this->values[$parameter] = $value;
3970  if (!is_null($type)) {
3971  $this->types[$parameter] = $type;
3972  }
3973  return MDB2_OK;
3974  }
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
const MDB2_ERROR_NOT_FOUND
Definition: MDB2.php:76

◆ bindValueArray()

MDB2_Statement_Common::bindValueArray (   $values,
  $types = null 
)

Set the values of multiple a parameter of a prepared query in bulk.

Parameters
arrayspecifies all necessary information for bindValue() the array elements must use keys corresponding to the number of the position of the parameter.
arrayspecifies the types of the fields
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

See also
bindParam()

Definition at line 3992 of file MDB2.php.

References PEAR\isError(), and MDB2_OK.

3993  {
3994  $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
3995  $parameters = array_keys($values);
3996  foreach ($parameters as $key => $parameter) {
3997  $err = $this->bindValue($parameter, $values[$parameter], $types[$key]);
3998  if (PEAR::isError($err)) {
3999  return $err;
4000  }
4001  }
4002  return MDB2_OK;
4003  }
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
bindValue($parameter, $value, $type=null)
Set the value of a parameter of a prepared query.
Definition: MDB2.php:3960
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ execute()

& MDB2_Statement_Common::execute (   $values = null,
  $result_class = true,
  $result_wrap_class = false 
)

Execute a prepared query statement.

Parameters
arrayspecifies all necessary information for bindParam() the array elements must use keys corresponding to the number of the position of the parameter.
mixedspecifies which result class to use
mixedspecifies which class to wrap results in
Returns
mixed a result handle or MDB2_OK on success, a MDB2 error on failure

public

Definition at line 4082 of file MDB2.php.

References $result, array, PEAR\isError(), and MDB2_ERROR.

4083  {
4084  if (is_null($this->positions)) {
4085  return $this->db->raiseError(MDB2_ERROR, null, null,
4086  'Prepared statement has already been freed', __FUNCTION__);
4087  }
4088 
4089  $values = (array)$values;
4090  if (!empty($values)) {
4091  $err = $this->bindValueArray($values);
4092  if (PEAR::isError($err)) {
4093  return $this->db->raiseError(MDB2_ERROR, null, null,
4094  'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
4095  }
4096  }
4097  $result =& $this->_execute($result_class, $result_wrap_class);
4098  return $result;
4099  }
$result
bindValueArray($values, $types=null)
Set the values of multiple a parameter of a prepared query in bulk.
Definition: MDB2.php:3992
& _execute($result_class=true, $result_wrap_class=false)
Execute a prepared query statement helper method.
Definition: MDB2.php:4114
const MDB2_ERROR
Definition: MDB2.php:73
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_Common::free ( )

Release resources allocated for the specified prepared query.

Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Definition at line 4160 of file MDB2.php.

References MDB2_ERROR, and MDB2_OK.

4161  {
4162  if (is_null($this->positions)) {
4163  return $this->db->raiseError(MDB2_ERROR, null, null,
4164  'Prepared statement has already been freed', __FUNCTION__);
4165  }
4166 
4167  $this->statement = null;
4168  $this->positions = null;
4169  $this->query = null;
4170  $this->types = null;
4171  $this->result_types = null;
4172  $this->limit = null;
4173  $this->is_manip = null;
4174  $this->offset = null;
4175  $this->values = null;
4176 
4177  return MDB2_OK;
4178  }
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
const MDB2_ERROR
Definition: MDB2.php:73

◆ MDB2_Statement_Common()

MDB2_Statement_Common::MDB2_Statement_Common ( $db,
$statement,
  $positions,
  $query,
  $types,
  $result_types,
  $is_manip = false,
  $limit = null,
  $offset = null 
)

PHP 4 Constructor.

Definition at line 3939 of file MDB2.php.

3940  {
3942  }
__construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip=false, $limit=null, $offset=null)
Constructor.
Definition: MDB2.php:3920

Field Documentation

◆ $db

MDB2_Statement_Common::$db

Definition at line 3904 of file MDB2.php.

◆ $is_manip

MDB2_Statement_Common::$is_manip

Definition at line 3912 of file MDB2.php.

◆ $limit

MDB2_Statement_Common::$limit

Definition at line 3910 of file MDB2.php.

◆ $offset

MDB2_Statement_Common::$offset

Definition at line 3911 of file MDB2.php.

◆ $query

MDB2_Statement_Common::$query

Definition at line 3906 of file MDB2.php.

◆ $result_types

MDB2_Statement_Common::$result_types

Definition at line 3907 of file MDB2.php.

◆ $statement

MDB2_Statement_Common::$statement

Definition at line 3905 of file MDB2.php.

◆ $types

MDB2_Statement_Common::$types

Definition at line 3908 of file MDB2.php.

◆ $values

MDB2_Statement_Common::$values = array()

Definition at line 3909 of file MDB2.php.


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