Source of file TableGateway.php
Size: 2,656 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Db/TableGateway/TableGateway.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Db\TableGateway; use Zend\Db\Adapter\AdapterInterface; use Zend\Db\ResultSet\ResultSet; use Zend\Db\ResultSet\ResultSetInterface; use Zend\Db\Sql\Sql; use Zend\Db\Sql\TableIdentifier; class TableGateway extends AbstractTableGateway { /** * Constructor * * @param string $table * @param AdapterInterface $adapter * @param Feature\AbstractFeature|Feature\FeatureSet|Feature\AbstractFeature[] $features * @param ResultSetInterface $resultSetPrototype * @param Sql $sql * @throws Exception\InvalidArgumentException */ public function __construct($table, AdapterInterface $adapter, $features = null, ResultSetInterface $resultSetPrototype = null, Sql $sql = null) { // table if (!(is_string($table) || $table instanceof TableIdentifier)) { throw new Exception\InvalidArgumentException('Table name must be a string or an instance of Zend\Db\Sql\TableIdentifier'); } $this->table = $table; // adapter $this->adapter = $adapter; // process features if ($features !== null) { if ($features instanceof Feature\AbstractFeature) { $features = array($features); } if (is_array($features)) { $this->featureSet = new Feature\FeatureSet($features); } elseif ($features instanceof Feature\FeatureSet) { $this->featureSet = $features; } else { throw new Exception\InvalidArgumentException( 'TableGateway expects $feature to be an instance of an AbstractFeature or a FeatureSet, or an array of AbstractFeatures' ); } } else { $this->featureSet = new Feature\FeatureSet(); } // result prototype $this->resultSetPrototype = ($resultSetPrototype) ?: new ResultSet; // Sql object (factory for select, insert, update, delete) $this->sql = ($sql) ?: new Sql($this->adapter, $this->table); // check sql object bound to same table if ($this->sql->getTable() != $this->table) { throw new Exception\InvalidArgumentException('The table inside the provided Sql object must match the table of this TableGateway'); } $this->initialize(); } } |