ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 MDB2_Statement_Common (&$db, &$statement, $positions, $query, $types, $result_types, $is_manip=false, $limit=null, $offset=null)
 PHP 4 Constructor.
 bindValue ($parameter, $value, $type=null)
 Set the value of a parameter of a prepared query.
 bindValueArray ($values, $types=null)
 Set the values of multiple a parameter of a prepared query in bulk.
 bindParam ($parameter, &$value, $type=null)
 Bind a variable to a parameter of a prepared query.
 bindParamArray (&$values, $types=null)
 Bind the variables of multiple a parameter of a prepared query in bulk.
execute ($values=null, $result_class=true, $result_wrap_class=false)
 Execute a prepared query statement.
_execute ($result_class=true, $result_wrap_class=false)
 Execute a prepared query statement helper method.
 free ()
 Release resources allocated for the specified prepared query.

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

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.

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

Referenced by MDB2_Statement_Common().

{
$this->db =& $db;
$this->statement =& $statement;
$this->positions = $positions;
$this->query = $query;
$this->types = (array)$types;
$this->result_types = (array)$result_types;
$this->limit = $limit;
$this->is_manip = $is_manip;
$this->offset = $offset;
}

+ Here is the caller graph for this function:

Member Function Documentation

& 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

Reimplemented in MDB2_Statement_mysqli, MDB2_Statement_mysql, MDB2_Statement_oci8, and MDB2_Statement_pgsql.

Definition at line 4082 of file MDB2.php.

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

Referenced by execute().

{
$this->last_query = $this->query;
$query = '';
$last_position = 0;
foreach ($this->positions as $current_position => $parameter) {
if (!array_key_exists($parameter, $this->values)) {
return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
}
$value = $this->values[$parameter];
$query.= substr($this->query, $last_position, $current_position - $last_position);
if (!isset($value)) {
$value_quoted = 'NULL';
} else {
$type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
$value_quoted = $this->db->quote($value, $type);
if (PEAR::isError($value_quoted)) {
return $value_quoted;
}
}
$query.= $value_quoted;
$last_position = $current_position + 1;
}
$query.= substr($this->query, $last_position);
$this->db->offset = $this->offset;
$this->db->limit = $this->limit;
if ($this->is_manip) {
$result = $this->db->exec($query);
} else {
$result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References MDB2_ERROR_NOT_FOUND, and MDB2_OK.

Referenced by bindParamArray().

{
if (!is_numeric($parameter)) {
$parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
}
if (!in_array($parameter, $this->positions)) {
return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
}
$this->values[$parameter] =& $value;
if (!is_null($type)) {
$this->types[$parameter] = $type;
}
return MDB2_OK;
}

+ Here is the caller graph for this function:

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

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

{
$types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
$parameters = array_keys($values);
foreach ($parameters as $key => $parameter) {
$err = $this->bindParam($parameter, $values[$parameter], $types[$key]);
if (PEAR::isError($err)) {
return $err;
}
}
return MDB2_OK;
}

+ Here is the call graph for this function:

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

References MDB2_ERROR_NOT_FOUND, and MDB2_OK.

Referenced by bindValueArray().

{
if (!is_numeric($parameter)) {
$parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
}
if (!in_array($parameter, $this->positions)) {
return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
}
$this->values[$parameter] = $value;
if (!is_null($type)) {
$this->types[$parameter] = $type;
}
return MDB2_OK;
}

+ Here is the caller graph for this function:

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

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

Referenced by execute().

{
$types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
$parameters = array_keys($values);
foreach ($parameters as $key => $parameter) {
$err = $this->bindValue($parameter, $values[$parameter], $types[$key]);
if (PEAR::isError($err)) {
return $err;
}
}
return MDB2_OK;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
if (is_null($this->positions)) {
return $this->db->raiseError(MDB2_ERROR, null, null,
'Prepared statement has already been freed', __FUNCTION__);
}
$values = (array)$values;
if (!empty($values)) {
$err = $this->bindValueArray($values);
if (PEAR::isError($err)) {
return $this->db->raiseError(MDB2_ERROR, null, null,
'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
}
}
$result =& $this->_execute($result_class, $result_wrap_class);
return $result;
}

+ Here is the call graph for this function:

MDB2_Statement_Common::free ( )

Release resources allocated for the specified prepared query.

Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Reimplemented in MDB2_Statement_mysqli, MDB2_Statement_oci8, MDB2_Statement_mysql, and MDB2_Statement_pgsql.

Definition at line 4128 of file MDB2.php.

References MDB2_ERROR, and MDB2_OK.

{
if (is_null($this->positions)) {
return $this->db->raiseError(MDB2_ERROR, null, null,
'Prepared statement has already been freed', __FUNCTION__);
}
$this->statement = null;
$this->positions = null;
$this->query = null;
$this->types = null;
$this->result_types = null;
$this->limit = null;
$this->is_manip = null;
$this->offset = null;
$this->values = null;
return MDB2_OK;
}
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.

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

+ Here is the call graph for this function:

Field Documentation

MDB2_Statement_Common::$db

Definition at line 3872 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

MDB2_Statement_Common::$is_manip

Definition at line 3880 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

MDB2_Statement_Common::$limit

Definition at line 3878 of file MDB2.php.

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

MDB2_Statement_Common::$offset

Definition at line 3879 of file MDB2.php.

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

MDB2_Statement_Common::$result_types

Definition at line 3875 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

MDB2_Statement_Common::$statement

Definition at line 3873 of file MDB2.php.

Referenced by __construct(), and MDB2_Statement_Common().

MDB2_Statement_Common::$types

Definition at line 3876 of file MDB2.php.

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

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: