import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -51,6 +51,36 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
*/
|
||||
protected $_values;
|
||||
|
||||
/**
|
||||
* Check if LOB field are returned as string
|
||||
* instead of OCI-Lob object
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_lobAsString = false;
|
||||
|
||||
/**
|
||||
* Activate/deactivate return of LOB as string
|
||||
*
|
||||
* @param string $lob_as_string
|
||||
* @return Zend_Db_Statement_Oracle
|
||||
*/
|
||||
public function setLobAsString($lob_as_string)
|
||||
{
|
||||
$this->_lobAsString = (bool) $lob_as_string;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not LOB are returned as string
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getLobAsString()
|
||||
{
|
||||
return $this->_lobAsString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares statement handle
|
||||
*
|
||||
@ -279,21 +309,23 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
$style = $this->_fetchMode;
|
||||
}
|
||||
|
||||
$lob_as_string = $this->getLobAsString() ? OCI_RETURN_LOBS : 0;
|
||||
|
||||
switch ($style) {
|
||||
case Zend_Db::FETCH_NUM:
|
||||
$row = oci_fetch_row($this->_stmt);
|
||||
$row = oci_fetch_array($this->_stmt, OCI_NUM | OCI_RETURN_NULLS | $lob_as_string);
|
||||
break;
|
||||
case Zend_Db::FETCH_ASSOC:
|
||||
$row = oci_fetch_assoc($this->_stmt);
|
||||
$row = oci_fetch_array($this->_stmt, OCI_ASSOC | OCI_RETURN_NULLS | $lob_as_string);
|
||||
break;
|
||||
case Zend_Db::FETCH_BOTH:
|
||||
$row = oci_fetch_array($this->_stmt, OCI_BOTH);
|
||||
$row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
|
||||
break;
|
||||
case Zend_Db::FETCH_OBJ:
|
||||
$row = oci_fetch_object($this->_stmt);
|
||||
break;
|
||||
case Zend_Db::FETCH_BOUND:
|
||||
$row = oci_fetch_array($this->_stmt, OCI_BOTH);
|
||||
$row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
|
||||
if ($row !== false) {
|
||||
return $this->_fetchBound($row);
|
||||
}
|
||||
@ -320,6 +352,10 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
throw new Zend_Db_Statement_Oracle_Exception($error);
|
||||
}
|
||||
|
||||
if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
|
||||
unset($row['zend_db_rownum']);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -404,6 +440,11 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
if ($style == Zend_Db::FETCH_COLUMN) {
|
||||
$result = $result[$col];
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
|
||||
unset($row['zend_db_rownum']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (($row = oci_fetch_object($this->_stmt)) !== false) {
|
||||
$result [] = $row;
|
||||
@ -435,7 +476,15 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
}
|
||||
|
||||
if (!oci_fetch($this->_stmt)) {
|
||||
/* TODO ERROR */
|
||||
// if no error, there is simply no record
|
||||
if (!$error = oci_error($this->_stmt)) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Oracle_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Oracle/Exception.php';
|
||||
throw new Zend_Db_Statement_Oracle_Exception($error);
|
||||
}
|
||||
|
||||
$data = oci_result($this->_stmt, $col+1); //1-based
|
||||
@ -446,10 +495,18 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
require_once 'Zend/Db/Statement/Oracle/Exception.php';
|
||||
throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
|
||||
}
|
||||
|
||||
if ($this->getLobAsString()) {
|
||||
// instanceof doesn't allow '-', we must use a temporary string
|
||||
$type = 'OCI-Lob';
|
||||
if ($data instanceof $type) {
|
||||
$data = $data->read($data->size());
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches the next row and returns it as an object.
|
||||
*
|
||||
@ -466,12 +523,12 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
|
||||
$obj = oci_fetch_object($this->_stmt);
|
||||
|
||||
if ($obj === false) {
|
||||
if ($error = oci_error($this->_stmt)) {
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Oracle_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Oracle/Exception.php';
|
||||
throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
|
||||
throw new Zend_Db_Statement_Oracle_Exception($error);
|
||||
}
|
||||
|
||||
/* @todo XXX handle parameters */
|
||||
|
Reference in New Issue
Block a user