Skip to content

Commit

Permalink
Merge pull request #96 from mmuhasan/dev-where-bug-fix
Browse files Browse the repository at this point in the history
Fix the where clause issue to solve issue #73
  • Loading branch information
nilportugues authored Jul 19, 2018
2 parents 4decdb5 + 7a1275f commit a941d33
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ $query = $builder->select()
])
->where()
->greaterThan('user_id', 5)
->notLike('username', 'John');
->notLike('username', 'John')
->end();

echo $builder->writeFormatted($query);
```
Expand Down Expand Up @@ -242,7 +243,8 @@ $query = $builder->select()
->equals('user_id', 2)
->subWhere("OR")
->lessThan($column, 10)
->greaterThan('user_id', 100);
->greaterThan('user_id', 100)
->end();

echo $builder->writeFormatted($query);
```
Expand Down Expand Up @@ -297,7 +299,8 @@ $query = $builder->select()
$query
->where()
->greaterThan('user_id', 5)
->notLike('username', 'John');
->notLike('username', 'John')
->end();

$query
->orderBy('created_at', OrderBy::DESC);
Expand Down Expand Up @@ -456,7 +459,8 @@ $query = $builder->update()
'contact' => '[email protected]'
])
->where()
->equals('user_id', 1);
->equals('user_id', 1)
->end();

$sql = $builder->writeFormatted($query);
$values = $builder->getValues();
Expand Down Expand Up @@ -495,7 +499,8 @@ $query = $builder->update()
$query
->where()
->like('username', '%N')
->between('user_id', 1, 2000);
->between('user_id', 1, 2000)
->end();

$query
->orderBy('user_id', OrderBy::ASC)
Expand Down Expand Up @@ -561,7 +566,8 @@ $query = $builder->delete()

$query
->where()
->equals('user_id', 100);
->equals('user_id', 100)
->end();

$query
->limit(1);
Expand Down Expand Up @@ -593,7 +599,8 @@ $query = $builder->delete()
$query
->where()
->like('username', '%N')
->between('user_id', 1, 2000);
->between('user_id', 1, 2000)
->end();

$query
->orderBy('user_id', OrderBy::ASC)
Expand Down Expand Up @@ -809,7 +816,8 @@ $query = $builder->select()
->setTable('user')
->where('OR')
->equals('user_id', 1)
->like('name', '%N%');
->like('name', '%N%')
->end();

$sql = $builder->writeFormatted($query);
$values = $builder->getValues();
Expand Down Expand Up @@ -936,7 +944,8 @@ $query = $builder->select()
->setSelectAsColumn(array('user_role' => $selectRole))
->setSelectAsColumn(array($selectRole))
->where()
->equals('user_id', 4);
->equals('user_id', 4)
->end();

$sql = $builder->writeFormatted($query);
$values = $builder->getValues();
Expand Down Expand Up @@ -987,7 +996,8 @@ $query = $builder->select()
->setColumns(array('user_id', 'username'))
->setValueAsColumn('10', 'priority')
->where()
->equals('user_id', 1);
->equals('user_id', 1)
->end();

$sql = $builder->writeFormatted($query);
$values = $builder->getValues();
Expand Down Expand Up @@ -1021,7 +1031,8 @@ $query = $builder->select()
->setColumns(array('user_id', 'username'))
->setFunctionAsColumn('MAX', array('user_id'), 'max_id')
->where()
->equals('user_id', 1);
->equals('user_id', 1)
->end();

$sql = $builder->writeFormatted($query);
$values = $builder->getValues();
Expand Down Expand Up @@ -1053,7 +1064,8 @@ $query = $builder->select()
->setColumns(array('user_id', 'username'))
->setFunctionAsColumn('CURRENT_TIMESTAMP', array(), 'server_time')
->where()
->equals('user_id', 1);
->equals('user_id', 1)
->end();

$sql = $builder->writeFormatted($query);
$values = $builder->getValues();
Expand Down
8 changes: 8 additions & 0 deletions src/Syntax/Where.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,12 @@ public function getNull()
{
return $this->isNull;
}

/**
* @return QueryInterface
*/
public function end()
{
return $this->query;
}
}

0 comments on commit a941d33

Please sign in to comment.