3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Db\Sql\Platform\Mysql
;
12 use Zend\Db\Adapter\AdapterInterface
;
13 use Zend\Db\Adapter\Driver\DriverInterface
;
14 use Zend\Db\Adapter\ParameterContainer
;
15 use Zend\Db\Adapter\Platform\PlatformInterface
;
16 use Zend\Db\Adapter\StatementContainerInterface
;
17 use Zend\Db\Sql\Platform\PlatformDecoratorInterface
;
18 use Zend\Db\Sql\Select
;
20 class SelectDecorator
extends Select
implements PlatformDecoratorInterface
25 protected $select = null;
28 * @param Select $select
30 public function setSubject($select)
32 $this->select
= $select;
36 * @param AdapterInterface $adapter
37 * @param StatementContainerInterface $statementContainer
39 public function prepareStatement(AdapterInterface
$adapter, StatementContainerInterface
$statementContainer)
42 foreach (get_object_vars($this->select
) as $name => $value) {
43 $this->{$name} = $value;
45 parent
::prepareStatement($adapter, $statementContainer);
49 * @param PlatformInterface $platform
52 public function getSqlString(PlatformInterface
$platform = null)
55 foreach (get_object_vars($this->select
) as $name => $value) {
56 $this->{$name} = $value;
58 return parent
::getSqlString($platform);
61 protected function processLimit(PlatformInterface
$platform, DriverInterface
$driver = null, ParameterContainer
$parameterContainer = null)
63 if ($this->limit
=== null) {
67 $sql = $driver->formatParameterName('limit');
68 $parameterContainer->offsetSet('limit', (int) $this->limit
, ParameterContainer
::TYPE_INTEGER
);
76 protected function processOffset(PlatformInterface
$platform, DriverInterface
$driver = null, ParameterContainer
$parameterContainer = null)
78 if ($this->offset
=== null) {
82 $parameterContainer->offsetSet('offset', (int) $this->offset
, ParameterContainer
::TYPE_INTEGER
);
83 return array($driver->formatParameterName('offset'));
86 return array($this->offset
);