From afa35fc1527b9fd7d55541f17bf24d5a4047b307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Sat, 25 Nov 2023 13:51:12 +0800 Subject: [PATCH 01/28] remove compileInsertGetId --- .gitignore | 1 + src/Dm8/Query/Grammars/DmGrammar.php | 34 ++++++++++----------- src/Dm8/Query/Processors/DmProcessor.php | 38 ++++++++++++------------ 3 files changed, 37 insertions(+), 36 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..757fee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea \ No newline at end of file diff --git a/src/Dm8/Query/Grammars/DmGrammar.php b/src/Dm8/Query/Grammars/DmGrammar.php index 2f735c1..f2955d1 100644 --- a/src/Dm8/Query/Grammars/DmGrammar.php +++ b/src/Dm8/Query/Grammars/DmGrammar.php @@ -282,23 +282,23 @@ protected function wrapValue($value) * @param string $sequence * @return string */ - public function compileInsertGetId(Builder $query, $values, $sequence = 'id') - { - if (empty($sequence)) { - $sequence = 'id'; - } - - $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4)[2]['object']; - - if ($backtrace instanceof EloquentBuilder) { - $model = $backtrace->getModel(); - if ($model->sequence && ! isset($values[$model->getKeyName()]) && $model->incrementing) { - $values[$sequence] = null; - } - } - - return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence).' into ?'; - } + // public function compileInsertGetId(Builder $query, $values, $sequence = 'id') + // { + // if (empty($sequence)) { + // $sequence = 'id'; + // } + // + // $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4)[2]['object']; + // + // if ($backtrace instanceof EloquentBuilder) { + // $model = $backtrace->getModel(); + // if ($model->sequence && ! isset($values[$model->getKeyName()]) && $model->incrementing) { + // $values[$sequence] = null; + // } + // } + // + // return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence).' into ?'; + // } /** * Compile an insert statement into SQL. diff --git a/src/Dm8/Query/Processors/DmProcessor.php b/src/Dm8/Query/Processors/DmProcessor.php index afd661a..4ca64ec 100644 --- a/src/Dm8/Query/Processors/DmProcessor.php +++ b/src/Dm8/Query/Processors/DmProcessor.php @@ -19,25 +19,25 @@ class DmProcessor extends Processor * @param string $sequence * @return int */ - public function processInsertGetId(Builder $query, $sql, $values, $sequence = null) - { - $connection = $query->getConnection(); - - $connection->recordsHaveBeenModified(); - $start = microtime(true); - - $id = 0; - $parameter = 1; - $statement = $this->prepareStatement($query, $sql); - $values = $this->incrementBySequence($values, $sequence); - $parameter = $this->bindValues($values, $statement, $parameter); - $statement->bindParam($parameter, $id, PDO::PARAM_INT, -1); - $statement->execute(); - - $connection->logQuery($sql, $values, $start); - - return (int) $id; - } + // public function processInsertGetId(Builder $query, $sql, $values, $sequence = null) + // { + // $connection = $query->getConnection(); + // + // $connection->recordsHaveBeenModified(); + // $start = microtime(true); + // + // $id = 0; + // $parameter = 1; + // $statement = $this->prepareStatement($query, $sql); + // $values = $this->incrementBySequence($values, $sequence); + // $parameter = $this->bindValues($values, $statement, $parameter); + // $statement->bindParam($parameter, $id, PDO::PARAM_INT, -1); + // $statement->execute(); + // + // $connection->logQuery($sql, $values, $start); + // + // return (int) $id; + // } /** * Get prepared statement. From 867db7fbb150a0bc017278aed71438e4b733c26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Sat, 25 Nov 2023 13:53:08 +0800 Subject: [PATCH 02/28] update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a578781..87a806d 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,11 @@ { - "name": "jackfinal/laravel-dm8", + "name": "maxlcoder/laravel-dm8", "description": "php_dm dm8", "license": "MIT", "authors": [ { - "name": "Jack Final", - "email": "final_m@foxmail.com" + "name": "Woody", + "email": "liurenlin77@gmail.com" } ], "require": { From 11dcbc5c69ac920753be27dd3991b21976a99bf8 Mon Sep 17 00:00:00 2001 From: liurenlin Date: Mon, 27 Nov 2023 10:29:16 +0800 Subject: [PATCH 03/28] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index eb262e3..63c87e4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DM DB driver for Laravel 4|5|6|7|8|9 via DM8 +> This project modified something to fit Laravel,close to mysql; + ## Laravel-DM8 Laravel-DM8 is an Dm Database Driver package for [Laravel](http://laravel.com/). Laravel-DM8 is an extension of [Illuminate/Database](https://github.com/illuminate/database) that uses [DM8](https://eco.dameng.com/document/dm/zh-cn/faq/faq-php.html#PHP-Startup-Unable-to-load-dynamic-library) extension to communicate with Dm. Thanks to @yajra. From 9c87ccb6972d11aec1db7eb568666aa50fb9e039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Mon, 27 Nov 2023 18:44:41 +0800 Subject: [PATCH 04/28] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20DmBuilder=20?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/DmBuilder.php | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index 198cb17..7e24c49 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -14,29 +14,29 @@ class DmBuilder extends Builder * @param array $columns * @return array */ - protected function runPaginationCountQuery($columns = ['*']) - { - if ($this->groups || $this->havings) { - $clone = $this->cloneForPaginationCount(); - - if (is_null($clone->columns) && ! empty($this->joins)) { - $clone->select($this->from.'.*'); - } - - return $this->newQuery() - ->from(new Expression('('.$clone->toSql().')')) - ->mergeBindings($clone) - ->setAggregate('count', $this->withoutSelectAliases($columns)) - ->get()->all(); - } - - $without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset']; - - return $this->cloneWithout($without) - ->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order']) - ->setAggregate('count', $this->withoutSelectAliases($columns)) - ->get()->all(); - } + // protected function runPaginationCountQuery($columns = ['*']) + // { + // if ($this->groups || $this->havings) { + // $clone = $this->cloneForPaginationCount(); + // + // if (is_null($clone->columns) && ! empty($this->joins)) { + // $clone->select($this->from.'.*'); + // } + // + // return $this->newQuery() + // ->from(new Expression('('.$clone->toSql().')')) + // ->mergeBindings($clone) + // ->setAggregate('count', $this->withoutSelectAliases($columns)) + // ->get()->all(); + // } + // + // $without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset']; + // + // return $this->cloneWithout($without) + // ->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order']) + // ->setAggregate('count', $this->withoutSelectAliases($columns)) + // ->get()->all(); + // } /** * Get the count of the total records for the paginator. From 54f69d0952748501e73593e30601821f2bad2ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Mon, 27 Nov 2023 20:15:47 +0800 Subject: [PATCH 05/28] =?UTF-8?q?=E6=81=A2=E5=A4=8D=20DmBuilder=20?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/DmBuilder.php | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index 7e24c49..198cb17 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -14,29 +14,29 @@ class DmBuilder extends Builder * @param array $columns * @return array */ - // protected function runPaginationCountQuery($columns = ['*']) - // { - // if ($this->groups || $this->havings) { - // $clone = $this->cloneForPaginationCount(); - // - // if (is_null($clone->columns) && ! empty($this->joins)) { - // $clone->select($this->from.'.*'); - // } - // - // return $this->newQuery() - // ->from(new Expression('('.$clone->toSql().')')) - // ->mergeBindings($clone) - // ->setAggregate('count', $this->withoutSelectAliases($columns)) - // ->get()->all(); - // } - // - // $without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset']; - // - // return $this->cloneWithout($without) - // ->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order']) - // ->setAggregate('count', $this->withoutSelectAliases($columns)) - // ->get()->all(); - // } + protected function runPaginationCountQuery($columns = ['*']) + { + if ($this->groups || $this->havings) { + $clone = $this->cloneForPaginationCount(); + + if (is_null($clone->columns) && ! empty($this->joins)) { + $clone->select($this->from.'.*'); + } + + return $this->newQuery() + ->from(new Expression('('.$clone->toSql().')')) + ->mergeBindings($clone) + ->setAggregate('count', $this->withoutSelectAliases($columns)) + ->get()->all(); + } + + $without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset']; + + return $this->cloneWithout($without) + ->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order']) + ->setAggregate('count', $this->withoutSelectAliases($columns)) + ->get()->all(); + } /** * Get the count of the total records for the paginator. From 984b75cd8ce5e5fd005e58dc708932be3956fae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Wed, 29 Nov 2023 09:55:25 +0800 Subject: [PATCH 06/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Schema/DmBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dm8/Schema/DmBuilder.php b/src/Dm8/Schema/DmBuilder.php index 01117bb..c81a5e9 100644 --- a/src/Dm8/Schema/DmBuilder.php +++ b/src/Dm8/Schema/DmBuilder.php @@ -24,7 +24,7 @@ class DmBuilder extends Builder public function __construct(Connection $connection) { parent::__construct($connection); - $this->helper = new OracleAutoIncrementHelper($connection); + $this->helper = new DmAutoIncrementHelper($connection); $this->comment = new Comment($connection); } From c8d7be3a9e1cbd95e6c230bec434833704ebcf1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Wed, 29 Nov 2023 14:32:14 +0800 Subject: [PATCH 07/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20as=20=E5=90=8E?= =?UTF-8?q?=E8=A1=A8=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- src/Dm8/Query/Grammars/DmGrammar.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63c87e4..954f86f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # DM DB driver for Laravel 4|5|6|7|8|9 via DM8 -> This project modified something to fit Laravel,close to mysql; +> 修改部分适配 Laravel +> 1. 适配 InsertGetId +> 2. 修复 DmBuilder 中 DmAutoIncrementHelper 引用 +> 3. 适配 withCount, 主要是 x_table as y 情况 前缀补充,原包,没有在 y 前面追加前缀,和 Laravel 不兼容 ## Laravel-DM8 diff --git a/src/Dm8/Query/Grammars/DmGrammar.php b/src/Dm8/Query/Grammars/DmGrammar.php index f2955d1..3a9c3d8 100644 --- a/src/Dm8/Query/Grammars/DmGrammar.php +++ b/src/Dm8/Query/Grammars/DmGrammar.php @@ -233,7 +233,7 @@ public function wrapTable($table) $tableName = $this->wrap($this->tablePrefix.$table, true); $segments = explode(' ', $table); if (count($segments) > 1) { - $tableName = $this->wrap($this->tablePrefix.$segments[0]).' '.$segments[1]; + $tableName = $this->wrap($this->tablePrefix.$segments[0]).' ' . $this->tablePrefix . $segments[1]; } return $this->getSchemaPrefix().$tableName; From 216769a6cbc7994df29577b02acbc03b1b929aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Wed, 29 Nov 2023 19:15:07 +0800 Subject: [PATCH 08/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20DmBuilder=20=20isQue?= =?UTF-8?q?ryable=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/DmBuilder.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index 198cb17..fc7d18f 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -2,7 +2,10 @@ namespace LaravelDm8\Dm8\Query; +use Closure; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Database\Eloquent\Builder as EloquentBuilder; +use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Expression; From 5b7022343e6ad39fa246136d68c43e627cd2a841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Thu, 30 Nov 2023 10:35:09 +0800 Subject: [PATCH 09/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BE=BE=E6=A2=A6?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E6=95=8F=E6=84=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Dm8Connection.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Dm8/Dm8Connection.php b/src/Dm8/Dm8Connection.php index 92b93a1..e570a9c 100755 --- a/src/Dm8/Dm8Connection.php +++ b/src/Dm8/Dm8Connection.php @@ -452,23 +452,23 @@ protected function causedByLostConnection(Throwable $e) } /** - * Set oracle NLS session to case insensitive search & sort. + * Set dm NLS session to case insensitive search & sort. * * @return $this */ public function useCaseInsensitiveSession() { - return $this->setSessionVars(['NLS_COMP' => 'LINGUISTIC', 'NLS_SORT' => 'BINARY_CI']); + return $this->setSessionVars(['CASE_SENSITIVE' => 'FALSE']); } /** - * Set oracle NLS session to case sensitive search & sort. + * Set dm NLS session to case sensitive search & sort. * * @return $this */ public function useCaseSensitiveSession() { - return $this->setSessionVars(['NLS_COMP' => 'BINARY', 'NLS_SORT' => 'BINARY']); + return $this->setSessionVars(['CASE_SENSITIVE' => 'TRUE']); } /** From a6ec3a4fd312c71543215a50338ffbbfde6e15e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Fri, 1 Dec 2023 17:01:02 +0800 Subject: [PATCH 10/28] =?UTF-8?q?=E9=80=82=E9=85=8D=20cast=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + src/Dm8/Query/Grammars/DmGrammar.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 954f86f..3b5a5d1 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ > 1. 适配 InsertGetId > 2. 修复 DmBuilder 中 DmAutoIncrementHelper 引用 > 3. 适配 withCount, 主要是 x_table as y 情况 前缀补充,原包,没有在 y 前面追加前缀,和 Laravel 不兼容 +> 4. 适配 cast json ,数组参数转 json 入库 ## Laravel-DM8 diff --git a/src/Dm8/Query/Grammars/DmGrammar.php b/src/Dm8/Query/Grammars/DmGrammar.php index 3a9c3d8..86d93f9 100644 --- a/src/Dm8/Query/Grammars/DmGrammar.php +++ b/src/Dm8/Query/Grammars/DmGrammar.php @@ -590,4 +590,24 @@ protected function compileUnionAggregate(Builder $query) return $sql.' from ('.$this->compileSelect($query).') '.$this->wrapTable('temp_table'); } + + /** + * Prepare the bindings for an update statement. + * + * Booleans, integers, and doubles are inserted into JSON updates as raw values. + * + * @param array $bindings + * @param array $values + * @return array + */ + public function prepareBindingsForUpdate(array $bindings, array $values) + { + $values = collect($values)->reject(function ($value, $column) { + return $this->isJsonSelector($column) && is_bool($value); + })->map(function ($value) { + return is_array($value) ? json_encode($value) : $value; + })->all(); + + return parent::prepareBindingsForUpdate($bindings, $values); + } } From 8a304ea0925186f082c84d5cdbf6906f1c11e8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Fri, 1 Dec 2023 18:19:57 +0800 Subject: [PATCH 11/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + src/Dm8/Query/DmBuilder.php | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index 3b5a5d1..555ffff 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ > 2. 修复 DmBuilder 中 DmAutoIncrementHelper 引用 > 3. 适配 withCount, 主要是 x_table as y 情况 前缀补充,原包,没有在 y 前面追加前缀,和 Laravel 不兼容 > 4. 适配 cast json ,数组参数转 json 入库 +> 5. 兼容 mysql group_concat 函数,内部转化为 wm_concat 函数 ## Laravel-DM8 diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index fc7d18f..11d6ac7 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -263,4 +263,27 @@ public function clone() { return clone $this; } + + + /** + * Add a new "raw" select expression to the query. + * 达梦函数转化 + * + * @param string $expression + * @param array $bindings + * @return $this + */ + public function selectRaw($expression, array $bindings = []) + { + if (strpos(strtolower($expression), ' group_concat(') !== false) { + $expression = str_replace(' group_concat(', ' wm_concat(', $expression); + } + $this->addSelect(new Expression($expression)); + + if ($bindings) { + $this->addBinding($bindings, 'select'); + } + + return $this; + } } From 4599e341741c1ff43f26b2053acf67f678378c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Sat, 2 Dec 2023 09:59:09 +0800 Subject: [PATCH 12/28] updat readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 555ffff..3277a66 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Laravel-DM8 is an Dm Database Driver package for [Laravel](http://laravel.com/). ## Quick Installation ```bash -composer require jackfinal/laravel-dm8 +composer require maxlcoder/laravel-dm8 ``` ## Service Provider (Optional on Laravel 5.5+) From ae4660667dc4c0d4a5b1c098428856d9c4f050fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Sun, 7 Apr 2024 10:34:03 +0800 Subject: [PATCH 13/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20group=5Fconcat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/DmBuilder.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index 11d6ac7..fee81f4 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -151,15 +151,20 @@ public function whereIn($column, $values, $boolean = 'and', $not = false) */ protected function runSelect() { + $expression = strtolower($this->toSql()); + if (strpos($expression, ' group_concat(') !== false) { + $expression = str_replace(' group_concat(', ' wm_concat(', $expression); + } + if ($this->lock) { $this->connection->beginTransaction(); - $result = $this->connection->select($this->toSql(), $this->getBindings(), ! $this->useWritePdo); + $result = $this->connection->select($expression, $this->getBindings(), ! $this->useWritePdo); $this->connection->commit(); return $result; } - return $this->connection->select($this->toSql(), $this->getBindings(), ! $this->useWritePdo); + return $this->connection->select($$expression, $this->getBindings(), ! $this->useWritePdo); } /** @@ -275,7 +280,8 @@ public function clone() */ public function selectRaw($expression, array $bindings = []) { - if (strpos(strtolower($expression), ' group_concat(') !== false) { + $expression = strtolower($expression); + if (strpos($expression, ' group_concat(') !== false) { $expression = str_replace(' group_concat(', ' wm_concat(', $expression); } $this->addSelect(new Expression($expression)); From f7e235fdc2508e7e0b5647dbd829a04038ccac12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Sun, 7 Apr 2024 10:38:58 +0800 Subject: [PATCH 14/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/DmBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index fee81f4..4d54cea 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -164,7 +164,7 @@ protected function runSelect() return $result; } - return $this->connection->select($$expression, $this->getBindings(), ! $this->useWritePdo); + return $this->connection->select($expression, $this->getBindings(), ! $this->useWritePdo); } /** From 98c02b6a5de6e44f46b2ad59e8a238e6bdea2003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 9 Apr 2024 18:13:24 +0800 Subject: [PATCH 15/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Dm8Connection.php | 28 ++++++++++++------------ src/Dm8/Eloquent/DmEloquent.php | 2 +- src/Dm8/Query/DmBuilder.php | 10 ++++----- src/Dm8/Query/Processors/DmProcessor.php | 6 ++--- src/Dm8/Schema/Comment.php | 16 +++++++------- src/Dm8/Schema/DmAutoIncrementHelper.php | 4 ++-- src/Dm8/Schema/DmBuilder.php | 8 +++---- src/Dm8/Schema/Sequence.php | 2 +- src/Dm8/Schema/Trigger.php | 2 +- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Dm8/Dm8Connection.php b/src/Dm8/Dm8Connection.php index e570a9c..d9fd767 100755 --- a/src/Dm8/Dm8Connection.php +++ b/src/Dm8/Dm8Connection.php @@ -31,12 +31,12 @@ class Dm8Connection extends Connection protected $schema; /** - * @var \Yajra\Oci8\Schema\Sequence + * @var \LaravelDm8\Dm8\Schema\Sequence */ protected $sequence; /** - * @var \Yajra\Oci8\Schema\Trigger + * @var \LaravelDm8\Dm8\Schema\Trigger */ protected $trigger; @@ -107,7 +107,7 @@ public function setSessionVars(array $sessionVars) /** * Get sequence class. * - * @return \Yajra\Oci8\Schema\Sequence + * @return \LaravelDm8\Dm8\Schema\Sequence */ public function getSequence() { @@ -117,8 +117,8 @@ public function getSequence() /** * Set sequence class. * - * @param \Yajra\Oci8\Schema\Sequence $sequence - * @return \Yajra\Oci8\Schema\Sequence + * @param \LaravelDm8\Dm8\Schema\Sequence $sequence + * @return \LaravelDm8\Dm8\Schema\Sequence */ public function setSequence(Sequence $sequence) { @@ -138,8 +138,8 @@ public function getTrigger() /** * Set oracle trigger class. * - * @param \Yajra\Oci8\Schema\Trigger $trigger - * @return \Yajra\Oci8\Schema\Trigger + * @param \LaravelDm8\Dm8\Schema\Trigger $trigger + * @return \LaravelDm8\Dm8\Schema\Trigger */ public function setTrigger(Trigger $trigger) { @@ -191,11 +191,11 @@ public function setDateFormat($format = 'YYYY-MM-DD HH24:MI:SS') /** * Get doctrine driver. * - * @return \Doctrine\DBAL\Driver\OCI8\Driver|\Yajra\Oci8\PDO\Oci8Driver + * @return \Doctrine\DBAL\Driver\OCI8\Driver|\LaravelDm8\Dm8\PDO\DmDriver */ protected function getDoctrineDriver() { - return class_exists(Version::class) ? new DoctrineDriver : new Oci8Driver(); + return class_exists(Version::class) ? new DoctrineDriver : new DmDriver(); } /** @@ -326,7 +326,7 @@ public function createStatementFromFunction($functionName, array $bindings) /** * Get the default query grammar instance. * - * @return \Illuminate\Database\Grammar|\Yajra\Oci8\Query\Grammars\OracleGrammar + * @return \Illuminate\Database\Grammar|\LaravelDm8\Dm8\Query\Grammars\DmGrammar */ protected function getDefaultQueryGrammar() { @@ -336,7 +336,7 @@ protected function getDefaultQueryGrammar() /** * Set the table prefix and return the grammar. * - * @param \Illuminate\Database\Grammar|\Yajra\Oci8\Query\Grammars\OracleGrammar|\Yajra\Oci8\Schema\Grammars\OracleGrammar $grammar + * @param \Illuminate\Database\Grammar|\LaravelDm8\Dm8\Query\Grammars\DmGrammar|\LaravelDm8\Dm8\Schema\Grammars\DmGrammar $grammar * @return \Illuminate\Database\Grammar */ public function withTablePrefix(Grammar $grammar) @@ -347,7 +347,7 @@ public function withTablePrefix(Grammar $grammar) /** * Set the schema prefix and return the grammar. * - * @param \Illuminate\Database\Grammar|\Yajra\Oci8\Query\Grammars\OracleGrammar|\Yajra\Oci8\Schema\Grammars\OracleGrammar $grammar + * @param \Illuminate\Database\Grammar|\LaravelDm8\Dm8\Query\Grammars\DmGrammar|\LaravelDm8\Dm8\Schema\Grammars\DmGrammar $grammar * @return \Illuminate\Database\Grammar */ public function withSchemaPrefix(Grammar $grammar) @@ -370,7 +370,7 @@ protected function getConfigSchemaPrefix() /** * Get the default schema grammar instance. * - * @return \Illuminate\Database\Grammar|\Yajra\Oci8\Schema\Grammars\OracleGrammar + * @return \Illuminate\Database\Grammar|\LaravelDm8\Dm8\Schema\Grammars\DmGrammar */ protected function getDefaultSchemaGrammar() { @@ -380,7 +380,7 @@ protected function getDefaultSchemaGrammar() /** * Get the default post processor instance. * - * @return \Yajra\Oci8\Query\Processors\OracleProcessor + * @return \LaravelDm8\Dm8\Query\Processors\DmProcessor */ protected function getDefaultPostProcessor() { diff --git a/src/Dm8/Eloquent/DmEloquent.php b/src/Dm8/Eloquent/DmEloquent.php index 7f4652d..6504a8f 100644 --- a/src/Dm8/Eloquent/DmEloquent.php +++ b/src/Dm8/Eloquent/DmEloquent.php @@ -161,7 +161,7 @@ public function getQualifiedKeyName() /** * Get a new query builder instance for the connection. * - * @return \Illuminate\Database\Query\Builder|\Yajra\Oci8\Query\OracleBuilder + * @return \Illuminate\Database\Query\Builder|\LaravelDm8\Dm8\Query\DmBuilder */ protected function newBaseQueryBuilder() { diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index 4d54cea..7a96285 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -73,14 +73,14 @@ public function getCountForPagination($columns = ['*']) */ public function insertLob(array $values, array $binaries, $sequence = 'id') { - /** @var \Yajra\Oci8\Query\Grammars\OracleGrammar $grammar */ + /** @var \LaravelDm8\Dm8\Query\Grammars\DmGrammar $grammar */ $grammar = $this->grammar; $sql = $grammar->compileInsertLob($this, $values, $binaries, $sequence); $values = $this->cleanBindings($values); $binaries = $this->cleanBindings($binaries); - /** @var \Yajra\Oci8\Query\Processors\OracleProcessor $processor */ + /** @var \LaravelDm8\Dm8\Query\Processors\DmProcessor $processor */ $processor = $this->processor; return $processor->saveLob($this, $sql, $values, $binaries); @@ -98,14 +98,14 @@ public function updateLob(array $values, array $binaries, $sequence = 'id') { $bindings = array_values(array_merge($values, $this->getBindings())); - /** @var \Yajra\Oci8\Query\Grammars\OracleGrammar $grammar */ + /** @var \LaravelDm8\Dm8\Query\Grammars\DmGrammar $grammar */ $grammar = $this->grammar; $sql = $grammar->compileUpdateLob($this, $values, $binaries, $sequence); $values = $this->cleanBindings($bindings); $binaries = $this->cleanBindings($binaries); - /** @var \Yajra\Oci8\Query\Processors\OracleProcessor $processor */ + /** @var \LaravelDm8\Dm8\Query\Processors\DmProcessor $processor */ $processor = $this->processor; return $processor->saveLob($this, $sql, $values, $binaries); @@ -120,7 +120,7 @@ public function updateLob(array $values, array $binaries, $sequence = 'id') * @param mixed $values * @param string $boolean * @param bool $not - * @return \Illuminate\Database\Query\Builder|\Yajra\Oci8\Query\OracleBuilder + * @return \Illuminate\Database\Query\Builder|\LaravelDm8\Dm8\Query\DmBuilder */ public function whereIn($column, $values, $boolean = 'and', $not = false) { diff --git a/src/Dm8/Query/Processors/DmProcessor.php b/src/Dm8/Query/Processors/DmProcessor.php index 4ca64ec..34a6827 100644 --- a/src/Dm8/Query/Processors/DmProcessor.php +++ b/src/Dm8/Query/Processors/DmProcessor.php @@ -48,7 +48,7 @@ class DmProcessor extends Processor */ private function prepareStatement(Builder $query, $sql) { - /** @var \Yajra\Oci8\Oci8Connection $connection */ + /** @var \LaravelDm8\Dm8\Dm8Connection $connection */ $connection = $query->getConnection(); $pdo = $connection->getPdo(); @@ -69,9 +69,9 @@ protected function incrementBySequence(array $values, $sequence) if (! isset($builderArgs[1][0][$sequence])) { if ($builder instanceof EloquentBuilder) { - /** @var \Yajra\Oci8\Eloquent\OracleEloquent $model */ + /** @var \LaravelDm8\Dm8\Eloquent\DmEloquent $model */ $model = $builder->getModel(); - /** @var \Yajra\Oci8\Oci8Connection $connection */ + /** @var \LaravelDm8\Dm8\Dm8Connection $connection */ $connection = $model->getConnection(); if ($model->sequence && $model->incrementing) { $values[] = (int) $connection->getSequence()->nextValue($model->sequence); diff --git a/src/Dm8/Schema/Comment.php b/src/Dm8/Schema/Comment.php index 03fec00..586814e 100644 --- a/src/Dm8/Schema/Comment.php +++ b/src/Dm8/Schema/Comment.php @@ -26,9 +26,9 @@ public function __construct(Connection $connection) /** * Set table and column comments. * - * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint + * @param \LaravelDm8\Dm8\Schema\DmBlueprint $blueprint */ - public function setComments(OracleBlueprint $blueprint) + public function setComments(DmBlueprint $blueprint) { $this->commentTable($blueprint); @@ -41,9 +41,9 @@ public function setComments(OracleBlueprint $blueprint) * Run the comment on table statement. * Comment set by $table->comment = 'comment';. * - * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint + * @param \LaravelDm8\Dm8\Schema\DmBlueprint $blueprint */ - private function commentTable(OracleBlueprint $blueprint) + private function commentTable(DmBlueprint $blueprint) { $table = $this->wrapValue($blueprint->getTable()); @@ -67,9 +67,9 @@ protected function wrapValue($value) * Add comments set via fluent setter. * Comments set by $table->string('column')->comment('comment');. * - * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint + * @param \LaravelDm8\Dm8\Schema\DmBlueprint $blueprint */ - private function fluentComments(OracleBlueprint $blueprint) + private function fluentComments(DmBlueprint $blueprint) { foreach ($blueprint->getColumns() as $column) { if (isset($column['comment'])) { @@ -98,9 +98,9 @@ private function commentColumn($table, $column, $comment) * Add comments on columns. * Comments set by $table->commentColumns = ['column' => 'comment'];. * - * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint + * @param \LaravelDm8\Dm8\Schema\DmBlueprint $blueprint */ - private function commentColumns(OracleBlueprint $blueprint) + private function commentColumns(DmBlueprint $blueprint) { foreach ($blueprint->commentColumns as $column => $comment) { $this->commentColumn($blueprint->getTable(), $column, $comment); diff --git a/src/Dm8/Schema/DmAutoIncrementHelper.php b/src/Dm8/Schema/DmAutoIncrementHelper.php index 57b1fd5..3867bf9 100644 --- a/src/Dm8/Schema/DmAutoIncrementHelper.php +++ b/src/Dm8/Schema/DmAutoIncrementHelper.php @@ -13,12 +13,12 @@ class DmAutoIncrementHelper protected $connection; /** - * @var \Yajra\Oci8\Schema\Trigger + * @var \LaravelDm8\Dm8\Schema\Trigger */ protected $trigger; /** - * @var \Yajra\Oci8\Schema\Sequence + * @var \LaravelDm8\Dm8\Schema\Sequence */ protected $sequence; diff --git a/src/Dm8/Schema/DmBuilder.php b/src/Dm8/Schema/DmBuilder.php index c81a5e9..943047e 100644 --- a/src/Dm8/Schema/DmBuilder.php +++ b/src/Dm8/Schema/DmBuilder.php @@ -9,12 +9,12 @@ class DmBuilder extends Builder { /** - * @var \Yajra\Oci8\Schema\OracleAutoIncrementHelper + * @var \LaravelDm8\Dm8\Schema\DmAutoIncrementHelper */ public $helper; /** - * @var \Yajra\Oci8\Schema\Comment + * @var \LaravelDm8\Dm8\Schema\Comment */ public $comment; @@ -131,7 +131,7 @@ public function dropIfExists($table) */ public function hasTable($table) { - /** @var \Yajra\Oci8\Schema\Grammars\OracleGrammar $grammar */ + /** @var \LaravelDm8\Dm8\Schema\Grammars\DmGrammar $grammar */ $grammar = $this->grammar; $sql = $grammar->compileTableExists(); @@ -154,7 +154,7 @@ public function getColumnListing($table) { $database = $this->connection->getConfig('username'); $table = $this->connection->getTablePrefix().$table; - /** @var \Yajra\Oci8\Schema\Grammars\OracleGrammar $grammar */ + /** @var \LaravelDm8\Dm8\Schema\Grammars\DmGrammar $grammar */ $grammar = $this->grammar; $results = $this->connection->select($grammar->compileColumnExists($database, $table)); diff --git a/src/Dm8/Schema/Sequence.php b/src/Dm8/Schema/Sequence.php index 6787c47..925aab4 100644 --- a/src/Dm8/Schema/Sequence.php +++ b/src/Dm8/Schema/Sequence.php @@ -7,7 +7,7 @@ class Sequence { /** - * @var \Illuminate\Database\Connection|\Yajra\Oci8\Oci8Connection + * @var \Illuminate\Database\Connection|\LaravelDm8\Dm8\Dm8Connection */ protected $connection; diff --git a/src/Dm8/Schema/Trigger.php b/src/Dm8/Schema/Trigger.php index b8f64eb..83bcac6 100644 --- a/src/Dm8/Schema/Trigger.php +++ b/src/Dm8/Schema/Trigger.php @@ -11,7 +11,7 @@ class Trigger use Dm8ReservedWords; /** - * @var \Illuminate\Database\Connection|\Yajra\Oci8\Oci8Connection + * @var \Illuminate\Database\Connection|\LaravelDm8\Dm8\Dm8Connection */ protected $connection; From a83c336d4129561a8414076a904de0fe27b613b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 9 Apr 2024 18:20:17 +0800 Subject: [PATCH 16/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Schema/DmBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dm8/Schema/DmBuilder.php b/src/Dm8/Schema/DmBuilder.php index 943047e..d471175 100644 --- a/src/Dm8/Schema/DmBuilder.php +++ b/src/Dm8/Schema/DmBuilder.php @@ -59,7 +59,7 @@ public function create($table, Closure $callback) */ protected function createBlueprint($table, Closure $callback = null) { - $blueprint = new OracleBlueprint($table, $callback); + $blueprint = new DmBlueprint($table, $callback); $blueprint->setTablePrefix($this->connection->getTablePrefix()); return $blueprint; From a9d20062c97496b38aabc94c1b113f1d780e4ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 4 Jun 2024 14:13:40 +0800 Subject: [PATCH 17/28] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20selectRaw=20?= =?UTF-8?q?=E5=B0=8F=E5=86=99=E8=BD=AC=E6=8D=A2=EF=BC=8C=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E6=95=8F=E6=84=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/DmBuilder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index 7a96285..f932e60 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -280,10 +280,12 @@ public function clone() */ public function selectRaw($expression, array $bindings = []) { - $expression = strtolower($expression); if (strpos($expression, ' group_concat(') !== false) { $expression = str_replace(' group_concat(', ' wm_concat(', $expression); } + if (strpos($expression, ' GROUP_CONCAT(') !== false) { + $expression = str_replace(' GROUP_CONCAT(', ' WM_CONCAT(', $expression); + } $this->addSelect(new Expression($expression)); if ($bindings) { From 8f1a7bd0882317e6e3320d0af2a71e337c5ea2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 4 Jun 2024 15:16:18 +0800 Subject: [PATCH 18/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Connectors/DmConnector.php | 2 +- src/Dm8/Query/DmBuilder.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Dm8/Connectors/DmConnector.php b/src/Dm8/Connectors/DmConnector.php index 0a30ba8..6e120af 100755 --- a/src/Dm8/Connectors/DmConnector.php +++ b/src/Dm8/Connectors/DmConnector.php @@ -15,7 +15,7 @@ class DmConnector extends Connector implements ConnectorInterface * @var array */ protected $options = [ - PDO::ATTR_CASE => PDO::CASE_LOWER, + PDO::ATTR_CASE => PDO::CASE_NATURAL, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, diff --git a/src/Dm8/Query/DmBuilder.php b/src/Dm8/Query/DmBuilder.php index f932e60..7909af6 100644 --- a/src/Dm8/Query/DmBuilder.php +++ b/src/Dm8/Query/DmBuilder.php @@ -151,10 +151,13 @@ public function whereIn($column, $values, $boolean = 'and', $not = false) */ protected function runSelect() { - $expression = strtolower($this->toSql()); + $expression = $this->toSql(); if (strpos($expression, ' group_concat(') !== false) { $expression = str_replace(' group_concat(', ' wm_concat(', $expression); } + if (strpos($expression, ' GROUP_CONCAT(') !== false) { + $expression = str_replace(' GROUP_CONCAT(', ' WM_CONCAT(', $expression); + } if ($this->lock) { $this->connection->beginTransaction(); From f9a2ba5df6de60ffb9e2be63592adf842b8912ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 4 Jun 2024 15:30:02 +0800 Subject: [PATCH 19/28] updat readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3277a66..9356074 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DM DB driver for Laravel 4|5|6|7|8|9 via DM8 +## 推荐更新版本到 1.0.14 + > 修改部分适配 Laravel > 1. 适配 InsertGetId > 2. 修复 DmBuilder 中 DmAutoIncrementHelper 引用 From de62cbb7d5612757fcaa9cbbb45c837082e6c52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 20 Aug 2024 21:55:15 +0800 Subject: [PATCH 20/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E4=B8=AD=20exists=20=E5=92=8C=20unique?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E9=99=A4=E5=AF=B9=20getCount=20=E5=92=8C=20g?= =?UTF-8?q?etMultiCount=20=E7=9A=84=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++ .../Dm8DatabasePresenceVerifier.php | 56 +++++++++---------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 9356074..3e58d79 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # DM DB driver for Laravel 4|5|6|7|8|9 via DM8 +## 查询写法 +> 1. 使用 `selectRaw` 或者 `DB::raw` 函数查询时,如果当前数据库是忽略大小写的,一律返回小写字段名, + + ## 推荐更新版本到 1.0.14 > 修改部分适配 Laravel @@ -8,6 +12,7 @@ > 3. 适配 withCount, 主要是 x_table as y 情况 前缀补充,原包,没有在 y 前面追加前缀,和 Laravel 不兼容 > 4. 适配 cast json ,数组参数转 json 入库 > 5. 兼容 mysql group_concat 函数,内部转化为 wm_concat 函数 +> 6. 修复表单验证中 exists 和 unique,去除对 getCount 和 getMultiCount 的重写。原包是对 oracle 进行大小写不敏感设置,但是达梦数据库不支持 ## Laravel-DM8 diff --git a/src/Dm8/Validation/Dm8DatabasePresenceVerifier.php b/src/Dm8/Validation/Dm8DatabasePresenceVerifier.php index 4cba752..13efb7c 100755 --- a/src/Dm8/Validation/Dm8DatabasePresenceVerifier.php +++ b/src/Dm8/Validation/Dm8DatabasePresenceVerifier.php @@ -18,20 +18,20 @@ class Dm8DatabasePresenceVerifier extends DatabasePresenceVerifier * @param array $extra * @return int */ - public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = []) - { - $connection = $this->table($collection)->getConnection(); - - if (! $connection instanceof Dm8Connection) { - return parent::getCount($collection, $column, $value, $excludeId, $idColumn, $extra); - } - - $connection->useCaseInsensitiveSession(); - $count = parent::getCount($collection, $column, $value, $excludeId, $idColumn, $extra); - $connection->useCaseSensitiveSession(); - - return $count; - } +// public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = []) +// { +// $connection = $this->table($collection)->getConnection(); +// +// if (! $connection instanceof Dm8Connection) { +// return parent::getCount($collection, $column, $value, $excludeId, $idColumn, $extra); +// } +// +// $connection->useCaseInsensitiveSession(); +// $count = parent::getCount($collection, $column, $value, $excludeId, $idColumn, $extra); +// $connection->useCaseSensitiveSession(); +// +// return $count; +// } /** * Count the number of objects in a collection with the given values. @@ -42,18 +42,18 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol * @param array $extra * @return int */ - public function getMultiCount($collection, $column, array $values, array $extra = []) - { - $connection = $this->table($collection)->getConnection(); - - if (! $connection instanceof Dm8Connection) { - return parent::getMultiCount($collection, $column, $values, $extra); - } - - $connection->useCaseInsensitiveSession(); - $count = parent::getMultiCount($collection, $column, $values, $extra); - $connection->useCaseSensitiveSession(); - - return $count; - } +// public function getMultiCount($collection, $column, array $values, array $extra = []) +// { +// $connection = $this->table($collection)->getConnection(); +// +// if (! $connection instanceof Dm8Connection) { +// return parent::getMultiCount($collection, $column, $values, $extra); +// } +// +// $connection->useCaseInsensitiveSession(); +// $count = parent::getMultiCount($collection, $column, $values, $extra); +// $connection->useCaseSensitiveSession(); +// +// return $count; +// } } From 242be009c3b26c37fe5b0e1489dd8c0d759fa986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 20 Aug 2024 22:00:03 +0800 Subject: [PATCH 21/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E4=B8=AD=20exists=20=E5=92=8C=20unique?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E9=99=A4=E5=AF=B9=20getCount=20=E5=92=8C=20g?= =?UTF-8?q?etMultiCount=20=E7=9A=84=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e58d79..0869402 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ > 1. 使用 `selectRaw` 或者 `DB::raw` 函数查询时,如果当前数据库是忽略大小写的,一律返回小写字段名, -## 推荐更新版本到 1.0.14 +## 推荐更新版本到最新版 > 修改部分适配 Laravel > 1. 适配 InsertGetId From b6c2b6a624d929c2e89dd5c8e3459cef9aa154a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 15 Oct 2024 16:04:28 +0800 Subject: [PATCH 22/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=80=92=E5=A2=9E=EF=BC=8C=E5=8C=B9=E9=85=8D=20laravel=20migra?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Schema/DmBuilder.php | 2 +- src/Dm8/Schema/Grammars/DmGrammar.php | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Dm8/Schema/DmBuilder.php b/src/Dm8/Schema/DmBuilder.php index d471175..2757712 100644 --- a/src/Dm8/Schema/DmBuilder.php +++ b/src/Dm8/Schema/DmBuilder.php @@ -47,7 +47,7 @@ public function create($table, Closure $callback) $this->comment->setComments($blueprint); - $this->helper->createAutoIncrementObjects($blueprint, $table); + // $this->helper->createAutoIncrementObjects($blueprint, $table); } /** diff --git a/src/Dm8/Schema/Grammars/DmGrammar.php b/src/Dm8/Schema/Grammars/DmGrammar.php index 8bf0676..f81db41 100644 --- a/src/Dm8/Schema/Grammars/DmGrammar.php +++ b/src/Dm8/Schema/Grammars/DmGrammar.php @@ -454,6 +454,23 @@ public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Conne return (array) $rs; } + + /** + * Compile a table comment command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileTableComment(Blueprint $blueprint, Fluent $command) + { + return sprintf('COMMENT ON TABLE %s is %s', + $this->wrapTable($blueprint), + "'".str_replace("'", "''", $command->comment)."'" + ); + } + + /** * Create the column definition for a char type. * @@ -528,9 +545,7 @@ protected function typeLongText(Fluent $column) */ protected function typeInteger(Fluent $column) { - $length = ($column->length) ? $column->length : 10; - - return "number({$length},0)"; + return 'int'; } /** @@ -541,9 +556,7 @@ protected function typeInteger(Fluent $column) */ protected function typeBigInteger(Fluent $column) { - $length = ($column->length) ? $column->length : 19; - - return "number({$length},0)"; + return 'bigint'; } /** @@ -813,6 +826,7 @@ protected function modifyIncrement(Blueprint $blueprint, Fluent $column) { if (in_array($column->type, $this->serials) && $column->autoIncrement) { $blueprint->primary($column->name); + return ' auto_increment'; } } From 45b726461783e987d09f309f77716b195b940d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 15 Oct 2024 16:12:51 +0800 Subject: [PATCH 23/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0869402..44ca89b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ > 4. 适配 cast json ,数组参数转 json 入库 > 5. 兼容 mysql group_concat 函数,内部转化为 wm_concat 函数 > 6. 修复表单验证中 exists 和 unique,去除对 getCount 和 getMultiCount 的重写。原包是对 oracle 进行大小写不敏感设置,但是达梦数据库不支持 +> 7. 修复自动递增,匹配 laravel migration。原包中将 migration 中的 int 和 bigint 均转化为 number 无法使 auto_increment 生效 ## Laravel-DM8 From c3505a0bed3f46300af9f23b0c0886ac12948608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Mon, 21 Oct 2024 17:19:06 +0800 Subject: [PATCH 24/28] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=92=8C=E8=A7=A6=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Schema/DmAutoIncrementHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dm8/Schema/DmAutoIncrementHelper.php b/src/Dm8/Schema/DmAutoIncrementHelper.php index 3867bf9..6ce3043 100644 --- a/src/Dm8/Schema/DmAutoIncrementHelper.php +++ b/src/Dm8/Schema/DmAutoIncrementHelper.php @@ -105,6 +105,7 @@ private function createObjectName($prefix, $table, $col, $type) */ public function dropAutoIncrementObjects($table) { + return true; // drop sequence and trigger object $prefix = $this->connection->getTablePrefix(); // get the actual primary column name from table From 6273e5a329096cdf5047897086dcd748da3947d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Fri, 25 Oct 2024 18:05:23 +0800 Subject: [PATCH 25/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Query/Grammars/DmGrammar.php | 34 ++++++++++----------- src/Dm8/Query/Processors/DmProcessor.php | 39 ++++++++++++------------ 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/Dm8/Query/Grammars/DmGrammar.php b/src/Dm8/Query/Grammars/DmGrammar.php index 86d93f9..5b8666f 100644 --- a/src/Dm8/Query/Grammars/DmGrammar.php +++ b/src/Dm8/Query/Grammars/DmGrammar.php @@ -282,23 +282,23 @@ protected function wrapValue($value) * @param string $sequence * @return string */ - // public function compileInsertGetId(Builder $query, $values, $sequence = 'id') - // { - // if (empty($sequence)) { - // $sequence = 'id'; - // } - // - // $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4)[2]['object']; - // - // if ($backtrace instanceof EloquentBuilder) { - // $model = $backtrace->getModel(); - // if ($model->sequence && ! isset($values[$model->getKeyName()]) && $model->incrementing) { - // $values[$sequence] = null; - // } - // } - // - // return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence).' into ?'; - // } + public function compileInsertGetId(Builder $query, $values, $sequence = 'id') + { + if (empty($sequence)) { + $sequence = 'id'; + } + + $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4)[2]['object']; + + if ($backtrace instanceof EloquentBuilder) { + $model = $backtrace->getModel(); + if ($model->sequence && ! isset($values[$model->getKeyName()]) && $model->incrementing) { + $values[$sequence] = null; + } + } + + return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence).' into ?'; + } /** * Compile an insert statement into SQL. diff --git a/src/Dm8/Query/Processors/DmProcessor.php b/src/Dm8/Query/Processors/DmProcessor.php index 34a6827..82b85e7 100644 --- a/src/Dm8/Query/Processors/DmProcessor.php +++ b/src/Dm8/Query/Processors/DmProcessor.php @@ -19,25 +19,26 @@ class DmProcessor extends Processor * @param string $sequence * @return int */ - // public function processInsertGetId(Builder $query, $sql, $values, $sequence = null) - // { - // $connection = $query->getConnection(); - // - // $connection->recordsHaveBeenModified(); - // $start = microtime(true); - // - // $id = 0; - // $parameter = 1; - // $statement = $this->prepareStatement($query, $sql); - // $values = $this->incrementBySequence($values, $sequence); - // $parameter = $this->bindValues($values, $statement, $parameter); - // $statement->bindParam($parameter, $id, PDO::PARAM_INT, -1); - // $statement->execute(); - // - // $connection->logQuery($sql, $values, $start); - // - // return (int) $id; - // } + public function processInsertGetId(Builder $query, $sql, $values, $sequence = null) + { + $connection = $query->getConnection(); + + $connection->recordsHaveBeenModified(); + $start = microtime(true); + + $id = 0; + $parameter = 1; + $statement = $this->prepareStatement($query, $sql); + $values = $this->incrementBySequence($values, $sequence); + $parameter = $this->bindValues($values, $statement, $parameter); + $statement->bindParam($parameter, $id, PDO::PARAM_INT, -1); + $statement->execute(); + + $values[] = '?'; + $connection->logQuery($sql, $values, $start); + + return (int) $id; + } /** * Get prepared statement. From ddd90475907e6e4200e582fcd1147fd22c6a1f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Tue, 29 Oct 2024 10:06:00 +0800 Subject: [PATCH 26/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Schema/Grammars/DmGrammar.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Dm8/Schema/Grammars/DmGrammar.php b/src/Dm8/Schema/Grammars/DmGrammar.php index f81db41..7fa290e 100644 --- a/src/Dm8/Schema/Grammars/DmGrammar.php +++ b/src/Dm8/Schema/Grammars/DmGrammar.php @@ -567,9 +567,7 @@ protected function typeBigInteger(Fluent $column) */ protected function typeMediumInteger(Fluent $column) { - $length = ($column->length) ? $column->length : 7; - - return "number({$length},0)"; + return 'int'; } /** @@ -580,9 +578,7 @@ protected function typeMediumInteger(Fluent $column) */ protected function typeSmallInteger(Fluent $column) { - $length = ($column->length) ? $column->length : 5; - - return "number({$length},0)"; + return 'smallint'; } /** @@ -593,9 +589,7 @@ protected function typeSmallInteger(Fluent $column) */ protected function typeTinyInteger(Fluent $column) { - $length = ($column->length) ? $column->length : 3; - - return "number({$length},0)"; + return 'tinyint'; } /** @@ -606,7 +600,7 @@ protected function typeTinyInteger(Fluent $column) */ protected function typeFloat(Fluent $column) { - return "number({$column->total}, {$column->places})"; + return $this->typeDouble($column); } /** @@ -617,7 +611,11 @@ protected function typeFloat(Fluent $column) */ protected function typeDouble(Fluent $column) { - return "number({$column->total}, {$column->places})"; + if ($column->total && $column->places) { + return "double({$column->total}, {$column->places})"; + } + + return 'double'; } /** @@ -628,7 +626,7 @@ protected function typeDouble(Fluent $column) */ protected function typeDecimal(Fluent $column) { - return "number({$column->total}, {$column->places})"; + return "decimal({$column->total}, {$column->places})"; } /** @@ -639,7 +637,7 @@ protected function typeDecimal(Fluent $column) */ protected function typeBoolean(Fluent $column) { - return 'char(1)'; + return 'tinyint(1)'; } /** From 10b3e709713e92a2628a977e8d8cdea075777fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Mon, 12 May 2025 19:50:33 +0800 Subject: [PATCH 27/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=BC=95?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dm8/Eloquent/DmEloquent.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Dm8/Eloquent/DmEloquent.php b/src/Dm8/Eloquent/DmEloquent.php index 6504a8f..9efbfce 100644 --- a/src/Dm8/Eloquent/DmEloquent.php +++ b/src/Dm8/Eloquent/DmEloquent.php @@ -6,8 +6,8 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Query\Builder as IlluminateQueryBuilder; use LaravelDm8\Dm8\Dm8Connection; -use LaravelDm8\Dm8\Query\Grammars\OracleGrammar; -use LaravelDm8\Dm8\Query\OracleBuilder as QueryBuilder; +use LaravelDm8\Dm8\Query\Grammars\DmGrammar; +use LaravelDm8\Dm8\Query\DmBuilder as QueryBuilder; class DmEloquent extends Model { @@ -168,7 +168,7 @@ protected function newBaseQueryBuilder() $conn = $this->getConnection(); $grammar = $conn->getQueryGrammar(); - if ($grammar instanceof OracleGrammar) { + if ($grammar instanceof DmGrammar) { return new QueryBuilder($conn, $grammar, $conn->getPostProcessor()); } From d1e1632dc37bb6dc56b9e69140b62f9f797c5579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BB=81=E9=BA=9F?= Date: Wed, 14 May 2025 15:19:06 +0800 Subject: [PATCH 28/28] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44ca89b..16104f2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## 推荐更新版本到最新版 > 修改部分适配 Laravel -> 1. 适配 InsertGetId +> 1. 适配 InsertGetId,当表主键非 id 时,需要指定主键列名 > 2. 修复 DmBuilder 中 DmAutoIncrementHelper 引用 > 3. 适配 withCount, 主要是 x_table as y 情况 前缀补充,原包,没有在 y 前面追加前缀,和 Laravel 不兼容 > 4. 适配 cast json ,数组参数转 json 入库