diff --git a/src/Sql/Abstracts/AbstractQueryBuilder.php b/src/Sql/Abstracts/AbstractQueryBuilder.php index 401fd8d..0636993 100644 --- a/src/Sql/Abstracts/AbstractQueryBuilder.php +++ b/src/Sql/Abstracts/AbstractQueryBuilder.php @@ -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 * @@ -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));