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

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 1434 of file mysqli.php.

Member Function Documentation

& MDB2_Statement_mysqli::_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 1446 of file mysqli.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;
}
if (!is_object($this->statement)) {
$query = 'EXECUTE '.$this->statement;
}
if (!empty($this->positions)) {
$parameters = array(0 => $this->statement, 1 => '');
$lobs = array();
$i = 0;
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_object($this->statement)) {
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;
}
} else {
if (is_resource($value) || $type == 'clob' || $type == 'blob') {
$parameters[] = null;
$parameters[1].= 'b';
$lobs[$i] = $parameter;
} else {
$parameters[] = $this->db->quote($value, $type, false);
$parameters[1].= $this->db->datatype->mapPrepareDatatype($type);
}
++$i;
}
}
if (!is_object($this->statement)) {
$query.= ' USING @'.implode(', @', array_values($this->positions));
} else {
// pear bug #17024: php 5.3 changed mysqli_stmt_bind_param()
$stmt_params = array();
foreach ($parameters as $k => &$value) {
$stmt_params[$k] = &$value;
}
$result = @call_user_func_array('mysqli_stmt_bind_param', $stmt_params);
if ($result === false) {
$err =& $this->db->raiseError(null, null, null,
'Unable to bind parameters', __FUNCTION__);
return $err;
}
foreach ($lobs as $i => $parameter) {
$value = $this->values[$parameter];
$close = false;
if (!is_resource($value)) {
$close = true;
if (preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
if ($match[1] == 'file://') {
$value = $match[2];
}
$value = @fopen($value, 'r');
} else {
$fp = @tmpfile();
@fwrite($fp, $value);
@rewind($fp);
$value = $fp;
}
}
while (!@feof($value)) {
$data = @fread($value, $this->db->options['lob_buffer_length']);
@mysqli_stmt_send_long_data($this->statement, $i, $data);
}
if ($close) {
@fclose($value);
}
}
}
}
if (!is_object($this->statement)) {
$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);
} else {
if (!@mysqli_stmt_execute($this->statement)) {
$err =& $this->db->raiseError(null, null, null,
'Unable to execute statement', __FUNCTION__);
return $err;
}
if ($this->is_manip) {
$affected_rows = @mysqli_stmt_affected_rows($this->statement);
return $affected_rows;
}
if ($this->db->options['result_buffering']) {
@mysqli_stmt_store_result($this->statement);
}
$result =& $this->db->_wrapResult($this->statement, $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_mysqli::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 1611 of file mysqli.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_object($this->statement)) {
if (!@mysqli_stmt_close($this->statement)) {
$result = $this->db->raiseError(null, null, null,
'Could not free statement', __FUNCTION__);
}
} elseif (!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: