Back to LegacyFactory class

Method createTable

public \Joomla\CMS\Table\Table
createTable
(mixed $name, mixed $prefix = 'Table', array $config = [])
Method to load and return a table object.
Parameters
  • string $name The name of the table.
  • string $prefix Optional table prefix.
  • array $config Optional configuration array for the table.
Returns
  • \Joomla\CMS\Table\Table The table object
Since
  • 3.10.0
-
  • \Exception
Class: LegacyFactory
Project: Joomla

Method createTable - Source code

/**
 * Method to load and return a table object.
 *
 * @param   string  $name    The name of the table.
 * @param   string  $prefix  Optional table prefix.
 * @param   array   $config  Optional configuration array for the table.
 *
 * @return  \Joomla\CMS\Table\Table  The table object
 *
 * @since   3.10.0
 * @throws  \Exception
 */
public function createTable($name, $prefix = 'Table', array $config = [])
{
    // Clean the model name
    $name = preg_replace('/[^A-Z0-9_]/i', '', $name);
    $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
    return Table::getInstance($name, $prefix, $config);
}