Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Using \Zend\Db\Sql\Expression as part of join name. Object of class Zend\Db\Sql\Expression could not be converted to string #6082

@joe-conigliaro

Description

@joe-conigliaro

In ZF1 I could do this

$select->join(array('mytable' => new Zend_Db_Expr('psql_function_which_returns_table')), 'mytable.id = other_table.mytable_id', array(
    'mytable.col',
))

However in ZF2

$select->join(array('mytable' => new \Zend\Db\Sql\Expression('psql_function_which_returns_table')), 'mytable.id = other_table.mytable_id', array(
    'mytable.col',
))

Throws an Exception: Object of class Zend\Db\Sql\Expression could not be converted to string...

I have proivided a diff for Zend\Db\Sql\Select.php which will allow this use case.

743c743,746
<             if ($joinName instanceof TableIdentifier) {

---
>             if ($joinName instanceof ExpressionInterface) {
>                 $joinName = $joinName->getExpression();
>             }
>             elseif ($joinName instanceof TableIdentifier) {
``

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions