zend-db icon indicating copy to clipboard operation
zend-db copied to clipboard

SQL Abstraction, Select API

Open dafap opened this issue 9 years ago • 3 comments

In the Select section, API description, replace

public function join(string|array $name, string $on, string|array $columns = self::SQL_STAR, string $type = self::JOIN_INNER) : self;

by

public function join(string|array $name, string|Zend\Db\Sql\ExpressionInterface $on, string|array $columns = self::SQL_STAR, string $type = self::JOIN_INNER) : self;

dafap avatar Oct 11 '16 13:10 dafap

@dafap I see $on is string in the source code. Can you give an example of $on accepting Zend\Db\Sql\ExpressionInterface? Thanks.

ezimuel avatar Apr 20 '17 19:04 ezimuel

This is possible using the ON clause as a ExpressionInterface :

$on = new Literal('browser_stats_daily.user_agent LIKE user_agents.user_agent');
$select = $this->tableGateway->getSql()->select();
$select->quantifier(Select::QUANTIFIER_DISTINCT)
       ->columns(["user_agent"])
       ->join("browser_stats_daily", $on, Select::SQL_STAR, Select::JOIN_RIGHT)
       ->where->isNotNull("user_agents.user_agent");

dafap avatar Apr 22 '17 06:04 dafap

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/93.

michalbundyra avatar Jan 16 '20 19:01 michalbundyra