ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
MDB2_Statement_mysql Class Reference
+ Inheritance diagram for MDB2_Statement_mysql:
+ Collaboration diagram for MDB2_Statement_mysql:

Public Member Functions

_execute ($result_class=true, $result_wrap_class=false)
 Execute a prepared query statement helper method.
 free ()
 Release resources allocated for the specified prepared query.
- Public Member Functions inherited from MDB2_Statement_Common
 __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.

Additional Inherited Members

- Data Fields inherited from MDB2_Statement_Common
 $db
 $statement
 $query
 $result_types
 $types
 $values = array()
 $limit
 $offset
 $is_manip

Detailed Description

Definition at line 1363 of file mysql.php.

Member Function Documentation

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

Execute a prepared query statement helper method.

Parameters
mixed$result_classstring which specifies which result class to use
mixed$result_wrap_classstring which specifies which class to wrap results in
Returns
mixed a result handle or MDB2_OK on success, a MDB2 error on failure private

Reimplemented from MDB2_Statement_Common.

Definition at line 1375 of file mysql.php.

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

{
if (is_null($this->statement)) {
$result =& parent::_execute($result_class, $result_wrap_class);
return $result;
}
$this->db->last_query = $this->query;
$this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values));
if ($this->db->getOption('disable_query')) {
$result = $this->is_manip ? 0 : null;
return $result;
}
$connection = $this->db->getConnection();
if (PEAR::isError($connection)) {
return $connection;
}
$query = 'EXECUTE '.$this->statement;
if (!empty($this->positions)) {
$parameters = array();
foreach ($this->positions as $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];
$type = array_key_exists($parameter, $this->types) ? $this->types[$parameter] : null;
if (is_resource($value) || $type == 'clob' || $type == 'blob') {
if (!is_resource($value) && preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
if ($match[1] == 'file://') {
$value = $match[2];
}
$value = @fopen($value, 'r');
$close = true;
}
if (is_resource($value)) {
$data = '';
while (!@feof($value)) {
$data.= @fread($value, $this->db->options['lob_buffer_length']);
}
if ($close) {
@fclose($value);
}
$value = $data;
}
}
$quoted = $this->db->quote($value, $type);
if (PEAR::isError($quoted)) {
return $quoted;
}
$param_query = 'SET @'.$parameter.' = '.$quoted;
$result = $this->db->_doQuery($param_query, true, $connection);
return $result;
}
}
$query.= ' USING @'.implode(', @', array_values($this->positions));
}
$result = $this->db->_doQuery($query, $this->is_manip, $connection);
return $result;
}
if ($this->is_manip) {
$affected_rows = $this->db->_affectedRows($connection, $result);
return $affected_rows;
}
$result =& $this->db->_wrapResult($result, $this->result_types,
$result_class, $result_wrap_class, $this->limit, $this->offset);
$this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result));
return $result;
}

+ Here is the call graph for this function:

MDB2_Statement_mysql::free ( )

Release resources allocated for the specified prepared query.

Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Reimplemented from MDB2_Statement_Common.

Definition at line 1460 of file mysql.php.

References MDB2_Statement_Common\$query, $result, PEAR\isError(), 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__);
}
if (!is_null($this->statement)) {
$connection = $this->db->getConnection();
if (PEAR::isError($connection)) {
return $connection;
}
$query = 'DEALLOCATE PREPARE '.$this->statement;
$result = $this->db->_doQuery($query, true, $connection);
}
return $result;
}

+ Here is the call graph for this function:


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