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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745585051a4634484.html
评论列表(0条)