admin管理员组文章数量:1433520
Is there any solution to get a list of default database tables in WordPress?
I have used $wpdb->tables()
but even with blog
argument, it returns a list that includes other tables too. (I have some plugins and they have created some more tables in database)
Is there any solution to get a list of default database tables in WordPress?
I have used $wpdb->tables()
but even with blog
argument, it returns a list that includes other tables too. (I have some plugins and they have created some more tables in database)
- Programmatically or just to get that list? It doesn’t change as often, so hardcoding it isn’t that bad solution, I guess... – Krzysiek Dróżdż Commented Apr 16, 2019 at 5:48
- I don't like hardcoding and writing the list manually. Searching for codes to do that. – Hector Commented Apr 16, 2019 at 5:50
- I'm curious, what do you need it for? – Jacob Peattie Commented Apr 16, 2019 at 6:11
- I need to show the size of each table as info for the user. But I don't like to include 3rd-party tables. – Hector Commented May 9, 2019 at 7:48
1 Answer
Reset to default 1There is no programmatic way to get a list of default tables. WordPress does not store a list of them anywhere. The closest thing there is is wp_get_db_schema()
. This function returns the raw SQL used to create the default tables, but as you can see from the source, it doesn't derive it from another source, it is where the default tables are originally defined. Maybe you could parse the SQL to figure it out, but I'm not sure why you'd need to.
本文标签: wpdbHow to get a list of WordPress default database tables
版权声明:本文标题:wpdb - How to get a list of WordPress default database tables? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745585050a2664850.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论