getTableList() clarification

Documentation is as important as the rest of the code, so if something is unclear, missing or just plain wrong, please tell it.
User avatar
matt_t_hat
Posts: 1123
Joined: Sun Aug 21, 2005 4:45 pm
Location: UK
Contact:

getTableList() clarification

Postby matt_t_hat » Fri Dec 02, 2011 3:32 pm

On the Overview of the class NucleusPlugin (redefinable methods) in the documentation here there is a vital part of the documentation for getTableList() that I feel could use clarification.

It has to do with the use of sql_table() which has been with use since v2.0.

Which is correct?

Code: Select all

getTableList(){
return array('plugin_bob_mytable','plugin_bob_myothertable');
}


or

Code: Select all

getTableList(){
return array(sql_table('plugin_bob_mytable'),sql_table('plugin_bob_myothertable'));
}


If I assume lazy programming than the second would be the case but if I assume user-oriented "helpful" programming that has made assumptions of it's own then I should choose the first.

However neither option feels satisfactory to me as a good example of the way such data should be handled.

Regardless of my own minor niggle I still need to know the format that is expected in the return array.
ftruscot
Nucleus Guru
Nucleus Guru
Posts: 7430
Joined: Wed Feb 22, 2006 6:19 pm
Location: Massachusetts
Contact:

Postby ftruscot » Fri Dec 02, 2011 4:43 pm

The method should return an array of table names ready for use by the backup process. It appears that the backup script takes each value returned in the array (as is), and tries to backup a table by that name.

So the plugin method getTableList() should return an array of table names as they appear in the db. For example, if a plugin implements this method in the following way (assuming a $MYSQL_PREFIX of 'lucy_'):

Code: Select all

function getTableList() {
   return array(
         sql_table('plug_myplugin_foo'),
         sql_table('plug_myplugin_bar'),
         'nucleus_fred_mertz',
         str_replace('fred','ethel','fred_mertz')
   );
}

The tables that would be backed up would be:

lucy_nucleus_plug_myplugin_foo,
lucy_nucleus_plug_myplugin_bar,
nucleus_fred_mertz,
ethel_mertz
Is your question not solved yet?
Search our FAQ,
read the Documentation, or
browse the list of available plugins.

Check out my plugins
User avatar
matt_t_hat
Posts: 1123
Joined: Sun Aug 21, 2005 4:45 pm
Location: UK
Contact:

Postby matt_t_hat » Fri Dec 02, 2011 6:13 pm

It's always good to clear these things up.

Return to “Documentation”