LoginSignup
2
2

More than 5 years have passed since last update.

Phalconでテーブル一覧を取得

Last updated at Posted at 2015-05-18

管理画面用にテーブル一覧が欲しかったのでメモ
(ryomojpさん情報ありがとうございます)

AnyController.php
$results = $this->db->listTables();

ちなみに、指定したテーブルのdescを取得するのも調べてみました。

AnyController.php
$this->db->describeColumns($tableName);

これで、Phalcon\Db\Columnの配列が返ってきます。


念のために過去記載分を残しておきます。

AnyController.php
// コネクションが欲しいだけなので、適当なモデルをnew
$model = new HogeModel();
// コネクションを取得
$connection = $model->getReadConnection();
// コネクションのlistTable()を使って取得(配列で返ってきます)
$result = $connection->listTables();
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2