Skip to content

Commit 90ddf02

Browse files
committed
Fixed psr-2 format in ezQuery
Missed a new line on the last commit. Also missed a param in the joining query description and some psr-2 changes. Also found an issue with $condition being used in $onCondition not being consistent.
1 parent ed8c2db commit 90ddf02

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

lib/ezQuery.php

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ public function leftJoin(
206206
string $leftColumn = null,
207207
string $rightColumn = null,
208208
string $tableAs = null,
209-
$condition = \EQ)
210-
{
209+
$condition = \EQ
210+
) {
211211
return $this->joining(
212212
'LEFT',
213213
$leftTable,
@@ -258,29 +258,30 @@ public function fullJoin(
258258
}
259259

260260
/**
261-
* For multiple select joins, combine rows from tables where `on` condition is met
262-
*
263-
* - Will perform an equal on tables by left column key,
264-
* left column key and left table, left column key and right table,
265-
* if `rightColumn` is null.
266-
*
267-
* - Will perform an equal on tables by,
268-
* left column key and left table, right column key and right table,
269-
* if `rightColumn` not null, and `$condition` not changed.
270-
*
271-
* - Will perform the `condition` on passed in arguments, for left column, and right column.
272-
* if `$condition`, is in the array
273-
*
274-
* @param string $type - Either `INNER`, `LEFT`, `RIGHT`, `FULL`
275-
* @param string $leftTable -
276-
* @param string $rightTable -
277-
*
278-
* @param string $leftColumn -
279-
* @param string $rightColumn -
280-
*
281-
* @param string $condition -
282-
*
283-
* @return bool|string JOIN sql statement, false for error
261+
* For multiple select joins, combine rows from tables where `on` condition is met
262+
*
263+
* - Will perform an equal on tables by left column key,
264+
* left column key and left table, left column key and right table,
265+
* if `rightColumn` is null.
266+
*
267+
* - Will perform an equal on tables by,
268+
* left column key and left table, right column key and right table,
269+
* if `rightColumn` not null, and `$condition` not changed.
270+
*
271+
* - Will perform the `condition` on passed in arguments, for left column, and right column.
272+
* if `$condition`, is in the array
273+
*
274+
* @param string $type - Either `INNER`, `LEFT`, `RIGHT`, `FULL`
275+
* @param string $leftTable -
276+
* @param string $rightTable -
277+
*
278+
* @param string $leftColumn -
279+
* @param string $rightColumn -
280+
* @param string $tableAs -
281+
*
282+
* @param string $condition -
283+
*
284+
* @return bool|string JOIN sql statement, false for error
284285
*/
285286
private function joining(
286287
String $type = \_INNER,
@@ -291,10 +292,12 @@ private function joining(
291292
string $tableAs = null,
292293
$condition = \EQ
293294
) {
294-
if (!\in_array($type, \_JOINERS)
295+
if (
296+
!\in_array($type, \_JOINERS)
295297
|| !\in_array($condition, \_BOOLEAN)
296298
|| empty($leftTable)
297-
|| empty($rightTable) || empty($leftColumn)
299+
|| empty($rightTable)
300+
|| empty($leftColumn)
298301
) {
299302
return false;
300303
}
@@ -303,13 +306,13 @@ private function joining(
303306
$tableAs = $rightTable;
304307

305308
if (\is_string($leftColumn) && empty($rightColumn))
306-
$onCondition = ' ON '.$leftTable.'.'.$leftColumn.' = '.$tableAs.'.'.$leftColumn;
309+
$onCondition = ' ON ' . $leftTable . '.' . $leftColumn . ' ' . $condition . ' ' . $tableAs . '.' . $leftColumn;
307310
elseif ($condition !== \EQ)
308-
$onCondition = ' ON '.$leftTable.'.'.$leftColumn." $condition ".$tableAs.'.'.$rightColumn;
311+
$onCondition = ' ON ' . $leftTable . '.' . $leftColumn . ' ' . $condition . ' ' . $tableAs . '.' . $rightColumn;
309312
else
310-
$onCondition = ' ON '.$leftTable.'.'.$leftColumn.' = '.$tableAs.'.'.$rightColumn;
313+
$onCondition = ' ON ' . $leftTable . '.' . $leftColumn . ' ' . $condition . ' ' . $tableAs . '.' . $rightColumn;
311314

312-
return ' '.$type.' JOIN '.$rightTable.' AS '.$tableAs.' '.$onCondition;
315+
return ' ' . $type . ' JOIN ' . $rightTable . ' AS ' . $tableAs . ' ' . $onCondition;
313316
}
314317

315318
public function orderBy($orderBy, $order)

0 commit comments

Comments
 (0)