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

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 1348 of file oci8.php.

Member Function Documentation

& MDB2_Statement_oci8::_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 1361 of file oci8.php.

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

{
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;
}
$lobs = $quoted_values = 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 ($type == 'clob' || $type == 'blob') {
$lobs[$i]['file'] = false;
if (is_resource($value)) {
$fp = $value;
$value = '';
while (!feof($fp)) {
$value.= fread($fp, 8192);
}
} elseif (preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
// ILIAS patch. We need interpretation as string not as file handle. alex 13.10.2009
// See ILIAS Mantis Bug #4636
// $lobs[$i]['file'] = true;
// if ($match[1] == 'file://') {
// $value = $match[2];
// }
}
$lobs[$i]['value'] = $value;
$lobs[$i]['descriptor'] = @OCINewDescriptor($connection, OCI_D_LOB);
if (!is_object($lobs[$i]['descriptor'])) {
$result = $this->db->raiseError(null, null, null,
'Unable to create descriptor for LOB in parameter: '.$parameter, __FUNCTION__);
break;
}
$lob_type = ($type == 'blob' ? OCI_B_BLOB : OCI_B_CLOB);
if (!@OCIBindByName($this->statement, ':'.$parameter, $lobs[$i]['descriptor'], -1, $lob_type)) {
$result = $this->db->raiseError($this->statement, null, null,
'could not bind LOB parameter', __FUNCTION__);
break;
}
} else {
$quoted_values[$i] = $this->db->quote($value, $type, false);
if (PEAR::isError($quoted_values[$i])) {
return $quoted_values[$i];
}
if (!@OCIBindByName($this->statement, ':'.$parameter, $quoted_values[$i])) {
$result = $this->db->raiseError($this->statement, null, null,
'could not bind non LOB parameter', __FUNCTION__);
break;
}
}
++$i;
}
$lob_keys = array_keys($lobs);
$mode = (!empty($lobs) || $this->db->in_transaction) ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
if (!@OCIExecute($this->statement, $mode)) {
$err =& $this->db->raiseError($this->statement, null, null,
'could not execute statement', __FUNCTION__);
return $err;
}
if (!empty($lobs)) {
foreach ($lob_keys as $i) {
if (!is_null($lobs[$i]['value']) && $lobs[$i]['value'] !== '') {
if ($lobs[$i]['file']) {
$result = $lobs[$i]['descriptor']->savefile($lobs[$i]['value']);
} else {
$result = $lobs[$i]['descriptor']->save($lobs[$i]['value']);
}
if (!$result) {
$result = $this->db->raiseError(null, null, null,
'Unable to save descriptor contents', __FUNCTION__);
break;
}
}
}
if (!$this->db->in_transaction) {
if (!@OCICommit($connection)) {
$result = $this->db->raiseError(null, null, null,
'Unable to commit transaction', __FUNCTION__);
}
} else {
++$this->db->uncommitedqueries;
}
}
}
}
$lob_keys = array_keys($lobs);
foreach ($lob_keys as $i) {
$lobs[$i]['descriptor']->free();
}
return $result;
}
if ($this->is_manip) {
$affected_rows = $this->db->_affectedRows($connection, $this->statement);
return $affected_rows;
}
$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_oci8::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 1499 of file oci8.php.

References $result, 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) && !@OCIFreeStatement($this->statement)) {
$result = $this->db->raiseError(null, null, null,
'Could not free statement', __FUNCTION__);
}
return $result;
}

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