Joomla 3.4 PHP basic:About JTable::getInstance in libraries/joomla/table/table.php file -
i trying read , understand joomla core php code when came across function. located in libraries/joomla/table/table.php
line 268. @ end of function in line 305, returns object created $tableclass
, don't understand is, $tableclass
class defined? following complete list of function:
public static function getinstance($type, $prefix = 'jtable', $config = array()) { // sanitize , prepare table class name. $type = preg_replace('/[^a-z0-9_\.-]/i', '', $type); $tableclass = $prefix . ucfirst($type); // try load class if doesn't exist. if (!class_exists($tableclass)) { // search class file in jtable include paths. jimport('joomla.filesystem.path'); $paths = self::addincludepath(); $pathindex = 0; while (!class_exists($tableclass) && $pathindex < count($paths)) { if ($trythis = jpath::find($paths[$pathindex++], strtolower($type) . '.php')) { // import class file. include_once $trythis; } } if (!class_exists($tableclass)) { // if unable find class file in jtable include paths, raise warning , return false. jlog::add(jtext::sprintf('jlib_database_error_not_supported_file_not_found', $type), jlog::warning, 'jerror'); return false; } } // if database object passed in configuration array use it, otherwise global 1 jfactory. $db = isset($config['dbo']) ? $config['dbo'] : jfactory::getdbo(); // instantiate new table class , return it. return new $tableclass($db); }
you can find jtable classes in tables subfolder in administration part of component. each file contain table class extends jtable class. don't have override method getinstance. in fact jtable can simple. example:
class xxxtablecity extends jtable { /** * constructor * * @param object database connector object */ function __construct( &$db ) { parent::__construct('#__xxx_cities', 'id', $db); } }
Comments
Post a Comment