ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 3906 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 3926 of file MDB2.php.

References $query, and array.

3927  {
3928  $this->db =& $db;
3929  $this->statement =& $statement;
3930  $this->positions = $positions;
3931  $this->query = $query;
3932  $this->types = (array)$types;
3933  $this->result_types = (array)$result_types;
3934  $this->limit = $limit;
3935  $this->is_manip = $is_manip;
3936  $this->offset = $offset;
3937  }
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 4120 of file MDB2.php.

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

4121  {
4122  $this->last_query = $this->query;
4123  $query = '';
4124  $last_position = 0;
4125  foreach ($this->positions as $current_position => $parameter) {
4126  if (!array_key_exists($parameter, $this->values)) {
4127  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
4128  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4129  }
4130  $value = $this->values[$parameter];
4131  $query.= substr($this->query, $last_position, $current_position - $last_position);
4132  if (!isset($value)) {
4133  $value_quoted = 'NULL';
4134  } else {
4135  $type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
4136  $value_quoted = $this->db->quote($value, $type);
4137  if (PEAR::isError($value_quoted)) {
4138  return $value_quoted;
4139  }
4140  }
4141  $query.= $value_quoted;
4142  $last_position = $current_position + 1;
4143  }
4144  $query.= substr($this->query, $last_position);
4145 
4146  $this->db->offset = $this->offset;
4147  $this->db->limit = $this->limit;
4148  if ($this->is_manip) {
4149  $result = $this->db->exec($query);
4150  } else {
4151  $result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
4152  }
4153  return $result;
4154  }
$result
$type
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 4027 of file MDB2.php.

References $type, MDB2_ERROR_NOT_FOUND, and MDB2_OK.

4028  {
4029  if (!is_numeric($parameter)) {
4030  $parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
4031  }
4032  if (!in_array($parameter, $this->positions)) {
4033  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
4034  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4035  }
4036  $this->values[$parameter] =& $value;
4037  if (!is_null($type)) {
4038  $this->types[$parameter] = $type;
4039  }
4040  return MDB2_OK;
4041  }
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
$type
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 4059 of file MDB2.php.

References $key, PEAR\isError(), and MDB2_OK.

4060  {
4061  $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4062  $parameters = array_keys($values);
4063  foreach ($parameters as $key => $parameter) {
4064  $err = $this->bindParam($parameter, $values[$parameter], $types[$key]);
4065  if (PEAR::isError($err)) {
4066  return $err;
4067  }
4068  }
4069  return MDB2_OK;
4070  }
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:4027
$key
Definition: croninfo.php:18
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 3966 of file MDB2.php.

References $type, MDB2_ERROR_NOT_FOUND, and MDB2_OK.

3967  {
3968  if (!is_numeric($parameter)) {
3969  $parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
3970  }
3971  if (!in_array($parameter, $this->positions)) {
3972  return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
3973  'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
3974  }
3975  $this->values[$parameter] = $value;
3976  if (!is_null($type)) {
3977  $this->types[$parameter] = $type;
3978  }
3979  return MDB2_OK;
3980  }
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
$type
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 3998 of file MDB2.php.

References $key, PEAR\isError(), and MDB2_OK.

3999  {
4000  $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4001  $parameters = array_keys($values);
4002  foreach ($parameters as $key => $parameter) {
4003  $err = $this->bindValue($parameter, $values[$parameter], $types[$key]);
4004  if (PEAR::isError($err)) {
4005  return $err;
4006  }
4007  }
4008  return MDB2_OK;
4009  }
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:3966
$key
Definition: croninfo.php:18
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 4088 of file MDB2.php.

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

4089  {
4090  if (is_null($this->positions)) {
4091  return $this->db->raiseError(MDB2_ERROR, null, null,
4092  'Prepared statement has already been freed', __FUNCTION__);
4093  }
4094 
4095  $values = (array)$values;
4096  if (!empty($values)) {
4097  $err = $this->bindValueArray($values);
4098  if (PEAR::isError($err)) {
4099  return $this->db->raiseError(MDB2_ERROR, null, null,
4100  'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
4101  }
4102  }
4103  $result =& $this->_execute($result_class, $result_wrap_class);
4104  return $result;
4105  }
$result
bindValueArray($values, $types=null)
Set the values of multiple a parameter of a prepared query in bulk.
Definition: MDB2.php:3998
& _execute($result_class=true, $result_wrap_class=false)
Execute a prepared query statement helper method.
Definition: MDB2.php:4120
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 4166 of file MDB2.php.

References MDB2_ERROR, and MDB2_OK.

4167  {
4168  if (is_null($this->positions)) {
4169  return $this->db->raiseError(MDB2_ERROR, null, null,
4170  'Prepared statement has already been freed', __FUNCTION__);
4171  }
4172 
4173  $this->statement = null;
4174  $this->positions = null;
4175  $this->query = null;
4176  $this->types = null;
4177  $this->result_types = null;
4178  $this->limit = null;
4179  $this->is_manip = null;
4180  $this->offset = null;
4181  $this->values = null;
4182 
4183  return MDB2_OK;
4184  }
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 3945 of file MDB2.php.

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

Field Documentation

◆ $db

MDB2_Statement_Common::$db

Definition at line 3910 of file MDB2.php.

◆ $is_manip

MDB2_Statement_Common::$is_manip

Definition at line 3918 of file MDB2.php.

◆ $limit

MDB2_Statement_Common::$limit

Definition at line 3916 of file MDB2.php.

◆ $offset

MDB2_Statement_Common::$offset

Definition at line 3917 of file MDB2.php.

◆ $query

MDB2_Statement_Common::$query

Definition at line 3912 of file MDB2.php.

◆ $result_types

MDB2_Statement_Common::$result_types

Definition at line 3913 of file MDB2.php.

◆ $statement

MDB2_Statement_Common::$statement

Definition at line 3911 of file MDB2.php.

◆ $types

MDB2_Statement_Common::$types

Definition at line 3914 of file MDB2.php.

◆ $values

MDB2_Statement_Common::$values = array()

Definition at line 3915 of file MDB2.php.


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