Admun's NUDN

admun

  • San Francisco, CA

Navigation

Navigation

Categories

Why sql_table...

Since Nucleus 2.5, sql_table() is introduced to construct the name of table name.

ie. sql_table('item') yields nucleus_item in a normal setup.

So, why a plugin should use this function to determine the table name, you ask?

I say, simple.

sql_table is added to support mutliple blogs setup using the same database, each blog setup can have a different table prefix so the two setup is not conflict to each other.

I am in the middle of sanitizing many plugins and found many old plugins wasn't update to use sql_table, in another word they will fail.

For backward compatibility, a plugin that is otherwise functioning in <2.5 should add the following function outside of the plugin class after adding sql_table in the code:

// plugin needs to work on Nucleus versions <=2.0 as well
if (!function_exists('sql_table')) {
function sql_table($name) { return 'nucleus_' . $name; }
}

It might also a good idea to add supportsFeature().

So, next time when you works on a plugin, be sure to use sql_table when refering to a table in a SQL query.

See here for details.

23:54:22 on 06/08/04 by Admun - Category: Developer Notes - tags: none - print

Comments

No comments yet

Add Comments