[wp-hackers] Taxonomy Schema Proposal

Mark Jaquith mark.wordpress at txfx.net
Sat Apr 21 06:06:09 GMT 2007


On Apr 20, 2007, at 3:25 PM, Ryan Boren wrote:

> I'm okay with a separate table as long as we're not joining on it
> everywhere.  The table could hold an auto_increment integer id and a
> varchar descriptive name.  This could be cached in an array stored in
> the options table.  Options are autoloaded so we won't be adding extra
> queries for front page loads.

Why not just have it stored as an option only?  It's not like there  
are going to be a lot of them, and the default ones can be assumed.   
Create an API for it.

function register_taxonomy($name) {
	if ( !taxonomy_exists($name) )
		return (int) create_taxonomy($name); // returns taxonomy id
	return (int) get_taxonomy_id($name);
}

And so forth.

Plugin would do:

define('MY_PLUGIN_CUSTOM_TAX_ID', register_taxonomy 
('my_custom_taxonomy'));

If it needed to do custom queries on that taxonomy id.  Otherwise,  
the built-in functions would do quick queryless taxonomy_name =>  
taxonomy_id conversion out of the in-memory options cache  
( get_taxonomy_id($name), for instance).

--
Mark Jaquith
http://markjaquith.com/

Covered Web Services
http://coveredwebservices.com/




More information about the wp-hackers mailing list