ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 3868 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 3888 of file MDB2.php.

3889 {
3890 $this->db =& $db;
3891 $this->statement =& $statement;
3892 $this->positions = $positions;
3893 $this->query = $query;
3894 $this->types = (array)$types;
3895 $this->result_types = (array)$result_types;
3896 $this->limit = $limit;
3897 $this->is_manip = $is_manip;
3898 $this->offset = $offset;
3899 }

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 4082 of file MDB2.php.

4083 {
4084 $this->last_query = $this->query;
4085 $query = '';
4086 $last_position = 0;
4087 foreach ($this->positions as $current_position => $parameter) {
4088 if (!array_key_exists($parameter, $this->values)) {
4089 return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
4090 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4091 }
4092 $value = $this->values[$parameter];
4093 $query.= substr($this->query, $last_position, $current_position - $last_position);
4094 if (!isset($value)) {
4095 $value_quoted = 'NULL';
4096 } else {
4097 $type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
4098 $value_quoted = $this->db->quote($value, $type);
4099 if (PEAR::isError($value_quoted)) {
4100 return $value_quoted;
4101 }
4102 }
4103 $query.= $value_quoted;
4104 $last_position = $current_position + 1;
4105 }
4106 $query.= substr($this->query, $last_position);
4107
4108 $this->db->offset = $this->offset;
4109 $this->db->limit = $this->limit;
4110 if ($this->is_manip) {
4111 $result = $this->db->exec($query);
4112 } else {
4113 $result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
4114 }
4115 return $result;
4116 }
$result
const MDB2_ERROR_NOT_FOUND
Definition: MDB2.php:71
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279

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 3989 of file MDB2.php.

3990 {
3991 if (!is_numeric($parameter)) {
3992 $parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
3993 }
3994 if (!in_array($parameter, $this->positions)) {
3995 return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
3996 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
3997 }
3998 $this->values[$parameter] =& $value;
3999 if (!is_null($type)) {
4000 $this->types[$parameter] = $type;
4001 }
4002 return MDB2_OK;
4003 }
const MDB2_OK
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
Definition: MDB2.php:67

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 4021 of file MDB2.php.

4022 {
4023 $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4024 $parameters = array_keys($values);
4025 foreach ($parameters as $key => $parameter) {
4026 $err = $this->bindParam($parameter, $values[$parameter], $types[$key]);
4027 if (PEAR::isError($err)) {
4028 return $err;
4029 }
4030 }
4031 return MDB2_OK;
4032 }
bindParam($parameter, &$value, $type=null)
Bind a variable to a parameter of a prepared query.
Definition: MDB2.php:3989

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 3928 of file MDB2.php.

3929 {
3930 if (!is_numeric($parameter)) {
3931 $parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
3932 }
3933 if (!in_array($parameter, $this->positions)) {
3934 return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
3935 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
3936 }
3937 $this->values[$parameter] = $value;
3938 if (!is_null($type)) {
3939 $this->types[$parameter] = $type;
3940 }
3941 return MDB2_OK;
3942 }

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 3960 of file MDB2.php.

3961 {
3962 $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
3963 $parameters = array_keys($values);
3964 foreach ($parameters as $key => $parameter) {
3965 $err = $this->bindValue($parameter, $values[$parameter], $types[$key]);
3966 if (PEAR::isError($err)) {
3967 return $err;
3968 }
3969 }
3970 return MDB2_OK;
3971 }
bindValue($parameter, $value, $type=null)
Set the value of a parameter of a prepared query.
Definition: MDB2.php:3928

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 4050 of file MDB2.php.

4051 {
4052 if (is_null($this->positions)) {
4053 return $this->db->raiseError(MDB2_ERROR, null, null,
4054 'Prepared statement has already been freed', __FUNCTION__);
4055 }
4056
4057 $values = (array)$values;
4058 if (!empty($values)) {
4059 $err = $this->bindValueArray($values);
4060 if (PEAR::isError($err)) {
4061 return $this->db->raiseError(MDB2_ERROR, null, null,
4062 'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
4063 }
4064 }
4065 $result =& $this->_execute($result_class, $result_wrap_class);
4066 return $result;
4067 }
const MDB2_ERROR
Definition: MDB2.php:68
bindValueArray($values, $types=null)
Set the values of multiple a parameter of a prepared query in bulk.
Definition: MDB2.php:3960
& _execute($result_class=true, $result_wrap_class=false)
Execute a prepared query statement helper method.
Definition: MDB2.php:4082

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 4128 of file MDB2.php.

4129 {
4130 if (is_null($this->positions)) {
4131 return $this->db->raiseError(MDB2_ERROR, null, null,
4132 'Prepared statement has already been freed', __FUNCTION__);
4133 }
4134
4135 $this->statement = null;
4136 $this->positions = null;
4137 $this->query = null;
4138 $this->types = null;
4139 $this->result_types = null;
4140 $this->limit = null;
4141 $this->is_manip = null;
4142 $this->offset = null;
4143 $this->values = null;
4144
4145 return MDB2_OK;
4146 }

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 3907 of file MDB2.php.

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

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 3872 of file MDB2.php.

Referenced by __construct().

◆ $is_manip

MDB2_Statement_Common::$is_manip

Definition at line 3880 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

◆ $limit

MDB2_Statement_Common::$limit

Definition at line 3878 of file MDB2.php.

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

◆ $offset

MDB2_Statement_Common::$offset

Definition at line 3879 of file MDB2.php.

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

◆ $query

◆ $result_types

MDB2_Statement_Common::$result_types

Definition at line 3875 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

◆ $statement

MDB2_Statement_Common::$statement

Definition at line 3873 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

◆ $types

MDB2_Statement_Common::$types

Definition at line 3876 of file MDB2.php.

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

◆ $values

MDB2_Statement_Common::$values = array()

Definition at line 3877 of file MDB2.php.

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


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