Class it_dbi:
/**
* Factory: Create classes of all database tables. Call statically.
* @param $p array(key => value) of configuration data
*/
static function createclasses($p = array())
{
# Make sure singleton exists
$dbi = $GLOBALS[static::$_global_key] ?: new static::$_global_key($p);
$p += $dbi->_p;
$dbid = "{$p['user']}@{$p['server']}:{$p['db']}";
$state = static::_state_get($dbid);
if (!$tables = $state['tables'])
{
$tables = $dbi->tables($p);
$state = static::_state_get($dbid); # State could have been modified by $db->tables() call
$state['tables'] = $tables;
static::_state_put($dbid, $state);
}
foreach ($tables as $table)
{
# Either create class in autoloader or manually just below
if (!class_exists($p['classprefix'] . $table))
static::createclass(array('table' => $table) + $p);
}
}