Skip to content

Commit

Permalink
Merge branch 'hotfix/db-oracle-interfaces-and-cs' of git://github.com…
Browse files Browse the repository at this point in the history
…/ralphschindler/zf2 into hotfix/3616
  • Loading branch information
weierophinney committed Jan 30, 2013
2 parents f26c3cf + 7664408 commit 70b1bcc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
3 changes: 1 addition & 2 deletions library/Zend/Db/Adapter/Driver/Oci8/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ class Result implements \Iterator, ResultInterface
/**
* Initialize
* @param resource $resource
* // param mixed $generatedValue
* // param bool|null $isBuffered
* @return Result
*/
public function initialize($resource /*, $generatedValue, $isBuffered = null*/)
Expand Down Expand Up @@ -147,6 +145,7 @@ public function current()
*/
protected function loadData()
{
$this->currentComplete = false;
$this->currentData = null;

$this->currentData = oci_fetch_assoc($this->resource);
Expand Down
11 changes: 7 additions & 4 deletions library/Zend/Db/Adapter/Driver/Oci8/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,16 @@ protected function bindParametersFromContainer()
foreach ($parameters as $name => &$value) {
if ($this->parameterContainer->offsetHasErrata($name)) {
switch ($this->parameterContainer->offsetGetErrata($name)) {
case ParameterContainer::TYPE_DOUBLE:
$type = SQLT_LNG;
break;
case ParameterContainer::TYPE_NULL:
$type = null;
$value = null;
break;
case ParameterContainer::TYPE_DOUBLE:
case ParameterContainer::TYPE_INTEGER:
$type = SQLT_INT;
if (is_string($value)) {
$value = (int) $value;
}
break;
case ParameterContainer::TYPE_STRING:
default:
Expand All @@ -288,7 +290,8 @@ protected function bindParametersFromContainer()
} else {
$type = SQLT_CHR;
}
oci_bind_by_name($this->resource, ':' . $name, $value, -1, $type);

oci_bind_by_name($this->resource, $name, $value, -1, $type);
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Db/Sql/Platform/Oracle/Oracle.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
//@Todo

namespace Zend\Db\Sql\Platform\Oracle;

use Zend\Db\Sql\Platform\AbstractPlatform;
Expand Down
37 changes: 17 additions & 20 deletions library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* Zend Framework (http://framework.zend.com/)
*
Expand All @@ -10,15 +9,15 @@

namespace Zend\Db\Sql\Platform\Oracle;

use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\AdapterInterface;
use Zend\Db\Adapter\Driver\DriverInterface;
use Zend\Db\Adapter\StatementContainerInterface;
use Zend\Db\Adapter\ParameterContainer;
use Zend\Db\Adapter\Platform\PlatformInterface;
use Zend\Db\Sql\ExpressionInterface;
use Zend\Db\Sql\Platform\PlatformDecoratorInterface;
use Zend\Db\Sql\Select;

//@Todo
class SelectDecorator extends Select implements PlatformDecoratorInterface
{

Expand All @@ -36,12 +35,11 @@ public function setSubject($select)
}

/**
* @param Adapter $adapter
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
*/
public function prepareStatement(Adapter $adapter, StatementContainerInterface $statementContainer)
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{

// localize variables
foreach (get_object_vars($this->select) as $name => $value) {
$this->{$name} = $value;
Expand Down Expand Up @@ -75,15 +73,14 @@ public function getSqlString(PlatformInterface $platform = null)

/**
* @param PlatformInterface $platform
* @param Adapter $adapter
* @param DriverInterface $driver
* @param ParameterContainer $parameterContainer
* @param $sqls
* @param $parameters
* @return null
*/
protected function processLimitOffset(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
{

if ($this->limit === null && $this->offset === null) {
return null;
}
Expand All @@ -102,39 +99,39 @@ protected function processLimitOffset(PlatformInterface $platform, Adapter $adap
}
}

if ($this->offset === null)
if ($this->offset === null) {
$this->offset = 0;
}

// first, produce column list without compound names (using the AS portion only)
array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(
array('SELECT %1$s FROM (SELECT b.%1$s, rownum b_rownum FROM (' => current($this->specifications[self::SELECT])), $selectParameters
));

array('SELECT %1$s FROM (SELECT b.%1$s, rownum b_rownum FROM (' => current($this->specifications[self::SELECT])), $selectParameters
));

if ($parameterContainer) {
// create bottom part of query, with offset and limit using row_number
array_push($sqls, ') b WHERE rownum <= (:offset+:limit)) WHERE b_rownum >= (:offset + 1)');

$parameterContainer->offsetSet('offset', $this->offset);
$parameterContainer->offsetSet('limit', $this->limit);
$parameterContainer->offsetSetReference('offsetForSum', 'offset');
$parameterContainer->offsetSet('offset', $this->offset, $parameterContainer::TYPE_INTEGER);
$parameterContainer->offsetSet('limit', $this->limit, $parameterContainer::TYPE_INTEGER);
} else {
array_push($sqls, ') b WHERE rownum <= ('
. (int) $this->offset
. '+'
. (int) $this->limit
. ')) WHERE b_rownum >= ('
. (int) $this->offset
. ' + 1)');
. ' + 1)'
);
}

$sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters(
$this->specifications[self::SELECT], $parameters[self::SELECT]
$this->specifications[self::SELECT], $parameters[self::SELECT]
);
}


protected function processJoins(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null)
protected function processJoins(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
{
if (!$this->joins) {
return null;
Expand All @@ -152,7 +149,7 @@ protected function processJoins(PlatformInterface $platform, Adapter $adapter =
: $platform->quoteIdentifier($join['name']);
// on expression
$joinSpecArgArray[$j][] = ($join['on'] instanceof ExpressionInterface)
? $this->processExpression($join['on'], $platform, $adapter, $this->processInfo['paramPrefix'] . 'join')
? $this->processExpression($join['on'], $platform, $driver, $this->processInfo['paramPrefix'] . 'join')
: $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN')); // on
if ($joinSpecArgArray[$j][2] instanceof StatementContainerInterface) {
if ($parameterContainer) {
Expand Down

0 comments on commit 70b1bcc

Please sign in to comment.