/** * When databases are present in the configuration file, they get * initialized in this function. */ public function setDatabases() { $databases = $this->get('Database'); if (!empty($databases)) { foreach ($databases as $id => $config) { DatabaseConnectionFactory::create($id, $config); } } }
/** * Constructor. * @param array $databaseConfiguration * @param Table $table Log table * @param bool|int $level The minimum logging level at which this handler will be triggered * @param boolean $bubble */ public function __construct(array $databaseConfiguration, Table $table, $level = Logger::DEBUG, $bubble = true) { DatabaseConnectionFactory::create(static::DATABASE, $databaseConfiguration); static::$table = $table; /* @todo Check if the table exists, otherwise create if (!$table->exists()) { } */ parent::__construct($level, $bubble); }
<?php function autoloader($class) { $include = __DIR__ . '/../Soneritics/' . $class . '.php'; require_once $include; } spl_autoload_register('autoloader'); \Database\DatabaseConnectionFactory::create('sandbox', ['type' => 'PDOMySQL', 'dsn' => 'mysql:dbname=sandbox;host=localhost', 'user' => 'sandbox', 'password' => 'sandbox']); $tables = Database\Database::getTables(); foreach ($tables as $table) { print_r($table); print_r($table->getColumns()); }