且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取我的数据库中所有表的名称

更新时间:2023-11-26 23:06:04

实际上,您可能不会使用 Propel 来获取这些信息,因为 Propel 只会在实际使用表时加载表映射信息.

原始架构文件在构建阶段使用(运行propel_gen om"等).Propel 的运行时部分从不查看 Schema 文件,因此无法查询它本身.

您的问题的答案是查看数据库,例如MySQL 查询以列出数据库中的表:显示 [完整] 表格 [{来自 |IN} db_name][喜欢'模式' |WHERE expr]

I need get the name of all the tables that exist on my database. I am usin Propel like my ORM. Actully i have been trying on this form.

$dbmap = \Propel::getDatabaseMap('data');
    $tablastmp = $dbmap->getTables();
    $tablas = array();
    foreach ($tablastmp as $tablatmp) {
        $tablas[] = $tablatmp->getName();
    }
    echo '<pre>';
    print_r($tablas);
    echo '</pre>';
    die();

but this return an array that is empty.

array();

And I need that return something like that:

array( [0] => 'clients', [1] => 'workers' );

Please someone help. I have been trying that for a few days.

Actually, you probably wouldn't use Propel to get this information as Propel only loads the table map information when the table is actually used.

The original Schema file is used during the build phase (running 'propel_gen om' etc). The runtime part of Propel never looks at the Schema file, so there is no way to query it per se.

The answer to your question is to look at the database, e.g. the MySQL query to list the tables in a database: SHOW [FULL] TABLES [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]