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.

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 }

References $db, $is_manip, $limit, $offset, $query, $result_types, $statement, and $types.

Referenced by MDB2_Statement_Common().

+ Here is the caller graph for this function:

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

@access private

Reimplemented in MDB2_Statement_mysql, MDB2_Statement_mysqli, MDB2_Statement_oci8, and MDB2_Statement_pgsql.

Definition at line 4114 of file MDB2.php.

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

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

Referenced by execute().

+ Here is the call graph for this function:
+ Here is the caller 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

@access public

Definition at line 4021 of file MDB2.php.

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

References MDB2_ERROR_NOT_FOUND, and MDB2_OK.

Referenced by bindParamArray().

+ Here is the caller graph for this function:

◆ 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

@access public

See also
bindParam()

Definition at line 4053 of file MDB2.php.

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 }
bindParam($parameter, &$value, $type=null)
Bind a variable to a parameter of a prepared query.
Definition: MDB2.php:4021

References $types, $values, bindParam(), PEAR\isError(), and MDB2_OK.

+ 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

@access public

Definition at line 3960 of file MDB2.php.

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 }

References MDB2_ERROR_NOT_FOUND, and MDB2_OK.

Referenced by bindValueArray().

+ Here is the caller graph for this function:

◆ 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

@access public

See also
bindParam()

Definition at line 3992 of file MDB2.php.

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 }
bindValue($parameter, $value, $type=null)
Set the value of a parameter of a prepared query.
Definition: MDB2.php:3960

References $types, $values, bindValue(), PEAR\isError(), and MDB2_OK.

Referenced by execute().

+ Here is the call graph for this function:
+ Here is the caller 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

@access public

Definition at line 4082 of file MDB2.php.

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 }
const MDB2_ERROR
Definition: MDB2.php:73
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

References $result, $values, _execute(), bindValueArray(), PEAR\isError(), and MDB2_ERROR.

+ 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

@access public

Reimplemented in MDB2_Statement_mysql, MDB2_Statement_mysqli, MDB2_Statement_oci8, and MDB2_Statement_pgsql.

Definition at line 4160 of file MDB2.php.

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 }

References MDB2_ERROR, and MDB2_OK.

◆ 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

References $is_manip, $limit, $offset, $query, $result_types, $statement, $types, and __construct().

+ Here is the call graph for this function:

Field Documentation

◆ $db

MDB2_Statement_Common::$db

Definition at line 3904 of file MDB2.php.

Referenced by __construct().

◆ $is_manip

MDB2_Statement_Common::$is_manip

Definition at line 3912 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

◆ $limit

MDB2_Statement_Common::$limit

Definition at line 3910 of file MDB2.php.

Referenced by __construct(), _execute(), and MDB2_Statement_Common().

◆ $offset

MDB2_Statement_Common::$offset

Definition at line 3911 of file MDB2.php.

Referenced by __construct(), _execute(), and MDB2_Statement_Common().

◆ $query

◆ $result_types

MDB2_Statement_Common::$result_types

Definition at line 3907 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

◆ $statement

MDB2_Statement_Common::$statement

Definition at line 3905 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

◆ $types

MDB2_Statement_Common::$types

Definition at line 3908 of file MDB2.php.

Referenced by __construct(), bindParamArray(), bindValueArray(), and MDB2_Statement_Common().

◆ $values

MDB2_Statement_Common::$values = array()

Definition at line 3909 of file MDB2.php.

Referenced by bindParamArray(), bindValueArray(), and execute().


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