Skip to content

Commit

Permalink
add get final statement method
Browse files Browse the repository at this point in the history
  • Loading branch information
Steeven Andrian committed Dec 6, 2019
1 parent 48329d3 commit 35f7213
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Sql/Abstracts/AbstractQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,26 @@ public function getSqlStatement($reset = true)

// ------------------------------------------------------------------------

/**
* AbstractQueryBuilder::getFinalSqlStatement
*
* @param bool $reset
*
* @return string
*/
public function getFinalSqlStatement($reset = true)
{
$sqlStatement = $this->conn->compileSqlBinds($this->getSqlStatement(false), $this->builderCache->binds);

if ($reset) {
$this->builderCache->reset();
}

return $sqlStatement;
}

// ------------------------------------------------------------------------

/**
* AbstractQueryBuilder::first
*
Expand Down Expand Up @@ -1257,6 +1277,11 @@ protected function prepareWhereStatement($field, $value = null, $type = 'AND ',

foreach ($field as $fieldName => $fieldValue) {
if ($fieldValue !== null) {
if ($fieldValue instanceof AbstractQueryBuilder) {
$this->builderCache->binds = array_merge($this->builderCache->binds, $fieldValue->builderCache->binds);
$fieldValue = $fieldValue->getSqlStatement();
}

$operator = $this->getOperator($fieldName);
$fieldName = trim(str_replace($operator, '', $fieldName));

Expand Down

0 comments on commit 35f7213

Please sign in to comment.