diff options
| author | lsces <lester@lsces.co.uk> | 2026-03-01 10:03:11 +0000 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2026-03-01 10:03:11 +0000 |
| commit | 9c628dc2d47c6ac1c1c07f620d1edac255315847 (patch) | |
| tree | 43c861c506207e7c3c12b6210872c7db9d60d3bf | |
| parent | f2c1c01679d92a329e9405ba4f5d43896180b4f6 (diff) | |
| download | illuminate-firebird-9c628dc2d47c6ac1c1c07f620d1edac255315847.tar.gz illuminate-firebird-9c628dc2d47c6ac1c1c07f620d1edac255315847.tar.bz2 illuminate-firebird-9c628dc2d47c6ac1c1c07f620d1edac255315847.zip | |
First cut at replacing mysql delete with firebird compatible one.
Tidying to use WHERE NOT EXISTS ( ) is on the todo list.
| -rwxr-xr-x | src/Query/Grammars/FirebirdGrammar.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Query/Grammars/FirebirdGrammar.php b/src/Query/Grammars/FirebirdGrammar.php index f7780dd..50cf731 100755 --- a/src/Query/Grammars/FirebirdGrammar.php +++ b/src/Query/Grammars/FirebirdGrammar.php @@ -79,6 +79,38 @@ class FirebirdGrammar extends Grammar } /** + * Compile a delete statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + public function compileDelete(Builder $query) + { + if (isset($query->joins) || isset($query->limit)) { + return $this->compileDeleteWithJoinsOrLimit($query); + } + + return parent::compileDelete($query); + } + + /** + * Compile a delete statement with joins or limit into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileDeleteWithJoinsOrLimit(Builder $query) + { + $table = $this->wrapTable($query->from); + + $alias = last(preg_split('/\s+as\s+/i', $query->from)); + + $selectSql = $this->compileSelect($query->select($alias.'.p_id')); + + return "delete from {$table} where {$this->wrap('p_id')} in ({$selectSql})"; + } + + /** * Compile the "limit" portions of the query. * * @param \Illuminate\Database\Query\Builder $query |
