ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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. More...
 
 free ()
 Release resources allocated for the specified prepared query. More...
 
- Public Member Functions inherited from MDB2_Statement_Common
 __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...
 

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

◆ _execute()

& 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 @access private

Reimplemented from MDB2_Statement_Common.

Definition at line 1361 of file oci8.php.

1362 {
1363 if (is_null($this->statement)) {
1364 $result =& parent::_execute($result_class, $result_wrap_class);
1365 return $result;
1366 }
1367 $this->db->last_query = $this->query;
1368 $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values));
1369 if ($this->db->getOption('disable_query')) {
1370 $result = $this->is_manip ? 0 : null;
1371 return $result;
1372 }
1373
1374 $connection = $this->db->getConnection();
1375 if (PEAR::isError($connection)) {
1376 return $connection;
1377 }
1378
1379 $result = MDB2_OK;
1380 $lobs = $quoted_values = array();
1381 $i = 0;
1382 foreach ($this->positions as $parameter) {
1383 if (!array_key_exists($parameter, $this->values)) {
1384 return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
1385 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
1386 }
1387 $value = $this->values[$parameter];
1388 $type = array_key_exists($parameter, $this->types) ? $this->types[$parameter] : null;
1389 if ($type == 'clob' || $type == 'blob') {
1390 $lobs[$i]['file'] = false;
1391 if (is_resource($value)) {
1392 $fp = $value;
1393 $value = '';
1394 while (!feof($fp)) {
1395 $value.= fread($fp, 8192);
1396 }
1397 } elseif (preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
1398// ILIAS patch. We need interpretation as string not as file handle. alex 13.10.2009
1399// See ILIAS Mantis Bug #4636
1400// $lobs[$i]['file'] = true;
1401// if ($match[1] == 'file://') {
1402// $value = $match[2];
1403// }
1404 }
1405 $lobs[$i]['value'] = $value;
1406 $lobs[$i]['descriptor'] = @OCINewDescriptor($connection, OCI_D_LOB);
1407 if (!is_object($lobs[$i]['descriptor'])) {
1408 $result = $this->db->raiseError(null, null, null,
1409 'Unable to create descriptor for LOB in parameter: '.$parameter, __FUNCTION__);
1410 break;
1411 }
1412 $lob_type = ($type == 'blob' ? OCI_B_BLOB : OCI_B_CLOB);
1413 if (!@OCIBindByName($this->statement, ':'.$parameter, $lobs[$i]['descriptor'], -1, $lob_type)) {
1414 $result = $this->db->raiseError($this->statement, null, null,
1415 'could not bind LOB parameter', __FUNCTION__);
1416 break;
1417 }
1418 } else {
1419 $quoted_values[$i] = $this->db->quote($value, $type, false);
1420 if (PEAR::isError($quoted_values[$i])) {
1421 return $quoted_values[$i];
1422 }
1423 if (!@OCIBindByName($this->statement, ':'.$parameter, $quoted_values[$i])) {
1424 $result = $this->db->raiseError($this->statement, null, null,
1425 'could not bind non LOB parameter', __FUNCTION__);
1426 break;
1427 }
1428 }
1429 ++$i;
1430 }
1431
1432 $lob_keys = array_keys($lobs);
1433 if (!PEAR::isError($result)) {
1434 $mode = (!empty($lobs) || $this->db->in_transaction) ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
1435 if (!@OCIExecute($this->statement, $mode)) {
1436 $err =& $this->db->raiseError($this->statement, null, null,
1437 'could not execute statement', __FUNCTION__);
1438 return $err;
1439 }
1440
1441 if (!empty($lobs)) {
1442 foreach ($lob_keys as $i) {
1443 if (!is_null($lobs[$i]['value']) && $lobs[$i]['value'] !== '') {
1444 if ($lobs[$i]['file']) {
1445 $result = $lobs[$i]['descriptor']->savefile($lobs[$i]['value']);
1446 } else {
1447 $result = $lobs[$i]['descriptor']->save($lobs[$i]['value']);
1448 }
1449 if (!$result) {
1450 $result = $this->db->raiseError(null, null, null,
1451 'Unable to save descriptor contents', __FUNCTION__);
1452 break;
1453 }
1454 }
1455 }
1456
1457 if (!PEAR::isError($result)) {
1458 if (!$this->db->in_transaction) {
1459 if (!@OCICommit($connection)) {
1460 $result = $this->db->raiseError(null, null, null,
1461 'Unable to commit transaction', __FUNCTION__);
1462 }
1463 } else {
1464 ++$this->db->uncommitedqueries;
1465 }
1466 }
1467 }
1468 }
1469
1470 $lob_keys = array_keys($lobs);
1471 foreach ($lob_keys as $i) {
1472 $lobs[$i]['descriptor']->free();
1473 }
1474
1475 if (PEAR::isError($result)) {
1476 return $result;
1477 }
1478
1479 if ($this->is_manip) {
1480 $affected_rows = $this->db->_affectedRows($connection, $this->statement);
1481 return $affected_rows;
1482 }
1483
1484 $result =& $this->db->_wrapResult($this->statement, $this->result_types,
1485 $result_class, $result_wrap_class, $this->limit, $this->offset);
1486 $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result));
1487 return $result;
1488 }
$result
const MDB2_OK
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
Definition: MDB2.php:67
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 MDB2_Statement_Common\$query, $result, PEAR\isError(), MDB2_ERROR_NOT_FOUND, and MDB2_OK.

+ Here is the call graph for this function:

◆ free()

MDB2_Statement_oci8::free ( )

Release resources allocated for the specified prepared query.

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

Reimplemented from MDB2_Statement_Common.

Definition at line 1499 of file oci8.php.

1500 {
1501 if (is_null($this->positions)) {
1502 return $this->db->raiseError(MDB2_ERROR, null, null,
1503 'Prepared statement has already been freed', __FUNCTION__);
1504 }
1505 $result = MDB2_OK;
1506
1507 if (!is_null($this->statement) && !@OCIFreeStatement($this->statement)) {
1508 $result = $this->db->raiseError(null, null, null,
1509 'Could not free statement', __FUNCTION__);
1510 }
1511
1512 parent::free();
1513 return $result;
1514 }
const MDB2_ERROR
Definition: MDB2.php:68

References $result, MDB2_ERROR, and MDB2_OK.


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