From fdfe2020cbe86d497a38f5d877e3b8c73b74cea4 Mon Sep 17 00:00:00 2001 From: Hal Wong Date: Mon, 28 Jun 2021 14:44:53 +0200 Subject: [PATCH] Add support for getTableNames() method from yii\db\Schema Class https://www.yiiframework.com/doc/api/2.0/yii-db-schema#getTableNames()-detail --- src/db/Schema.php | 60 +++++++++++++++++++++++++++++++ src/variables/ConnectVariable.php | 15 ++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/db/Schema.php diff --git a/src/db/Schema.php b/src/db/Schema.php new file mode 100644 index 0000000..d99f68a --- /dev/null +++ b/src/db/Schema.php @@ -0,0 +1,60 @@ +quoteSimpleTableName($schema); + } + + return $this->db->createCommand($sql)->queryColumn(); + } +} diff --git a/src/variables/ConnectVariable.php b/src/variables/ConnectVariable.php index f0be30f..9c5195b 100644 --- a/src/variables/ConnectVariable.php +++ b/src/variables/ConnectVariable.php @@ -12,6 +12,7 @@ use nystudio107\connect\Connect; use nystudio107\connect\db\Query; +use nystudio107\connect\db\Schema; use nystudio107\connect\models\Settings; use Craft; @@ -67,6 +68,20 @@ public function query($connection = null): Query ]); } + /** + * Returns a new generic schema. + * + * @param null|Connection $connection + * + * @return Schema + */ + public function schema($connection = null): Schema + { + return new Schema([ + 'db' => $connection, + ]); + } + // Protected Methods // =========================================================================