Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Zend\Db\Sql setTable method ommit array #4290

Merged
merged 5 commits into from

3 participants

@YannickDa

Add array type for setting table

@YannickDa YannickDa Update Sql.php
Add array type for setting table
e9ba17c
library/Zend/Db/Sql/Sql.php
@@ -48,7 +48,7 @@ public function hasTable()
public function setTable($table)
{
- if (is_string($table) || $table instanceof TableIdentifier) {
+ if (is_string($table) || is_array($table) || $table instanceof TableIdentifier) {
$this->table = $table;
} else {
throw new Exception\InvalidArgumentException('Table must be a string or instance of TableIdentifier.');

so the exception should be 'Table must be a string, array, or instance of TableIdentifier.'

Exact ! I have forget this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@YannickDa YannickDa Update Sql.php
Add information to the Exception
153035d
@samsonasik

then /** @var string / at protected $table should be /* @var array */
and in Zend\Db\Sql\Select.php
@param null|string $table in __construct should be @param null|string|array|TableIdentifier $table

YannickDa added some commits
@YannickDa YannickDa Update SqlTest.php
Modify the exception on SqlTest
38818cc
@YannickDa YannickDa Update Sql.php
Adding information to the protected $table relative to its type
7f2c9c0
@YannickDa YannickDa Update Select.php
Adding information about $table property
881bf08
@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler Merge PR #4290
Merge branch 'SqlSetTable' of git://github.com/YannickDa/zf2 into YannickDa-SqlSetTable
e6a933d
@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler Merge PR #4290 to master
Merge branch 'YannickDa-SqlSetTable'
95d32ec
@ralphschindler ralphschindler merged commit 881bf08 into from
@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler Forward PR #4290
Merge branch 'YannickDa-SqlSetTable' into develop
28354b2
@ghost Unknown referenced this pull request from a commit
@ralphschindler ralphschindler Merge PR #4290
Merge branch 'SqlSetTable' of git://github.com/YannickDa/zf2 into YannickDa-SqlSetTable
4f334e9
@ghost Unknown referenced this pull request from a commit
@ralphschindler ralphschindler Merge PR #4290 to master
Merge branch 'YannickDa-SqlSetTable'
6c1da0e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 22, 2013
  1. @YannickDa

    Update Sql.php

    YannickDa authored
    Add array type for setting table
  2. @YannickDa

    Update Sql.php

    YannickDa authored
    Add information to the Exception
Commits on Apr 25, 2013
  1. @YannickDa

    Update SqlTest.php

    YannickDa authored
    Modify the exception on SqlTest
  2. @YannickDa

    Update Sql.php

    YannickDa authored
    Adding information to the protected $table relative to its type
  3. @YannickDa

    Update Select.php

    YannickDa authored
    Adding information about $table property
This page is out of date. Refresh to see the latest.
View
4 library/Zend/Db/Sql/Select.php
@@ -96,7 +96,7 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface
protected $prefixColumnsWithTable = true;
/**
- * @var string|TableIdentifier
+ * @var string|array|TableIdentifier
*/
protected $table = null;
@@ -148,7 +148,7 @@ class Select extends AbstractSql implements SqlInterface, PreparableSqlInterface
/**
* Constructor
*
- * @param null|string $table
+ * @param null|string|array|TableIdentifier $table
*/
public function __construct($table = null)
{
View
6 library/Zend/Db/Sql/Sql.php
@@ -18,7 +18,7 @@ class Sql
/** @var AdapterInterface */
protected $adapter = null;
- /** @var string */
+ /** @var string|array|TableIdentifier */
protected $table = null;
/** @var Platform\Platform */
@@ -48,10 +48,10 @@ public function hasTable()
public function setTable($table)
{
- if (is_string($table) || $table instanceof TableIdentifier) {
+ if (is_string($table) || is_array($table) || $table instanceof TableIdentifier) {
$this->table = $table;
} else {
- throw new Exception\InvalidArgumentException('Table must be a string or instance of TableIdentifier.');
+ throw new Exception\InvalidArgumentException('Table must be a string, array or instance of TableIdentifier.');
}
return $this;
}
View
2  tests/ZendTest/Db/Sql/SqlTest.php
@@ -52,7 +52,7 @@ public function test__construct()
$sql->setTable('foo');
$this->assertSame('foo', $sql->getTable());
- $this->setExpectedException('Zend\Db\Sql\Exception\InvalidArgumentException', 'Table must be a string or instance of TableIdentifier.');
+ $this->setExpectedException('Zend\Db\Sql\Exception\InvalidArgumentException', 'Table must be a string, array or instance of TableIdentifier.');
$sql->setTable(null);
}
Something went wrong with that request. Please try again.