I am very confused about overlap I see between JDatabaseDriver and
JDatabaseFactory.
These methods are 100% the same code and exist in both classes:
getExporter, getImporter, getQuery.
This method is only in JDatabaseDriver, but I would expect it in
JDatabaseFactory: getIterator.
Is JDatabaseFactory the "entry point" to driver, exporter, importer, query,
and iterator? If so, can we remove the redundant methods from Driver (and
add Iterator to Factory?)
Also - JDatabaseFactory is confusing. It would make more sense (IMO) - if
an instance of JDatabaseFactory were statically made that included the
JDatabaseDriver connection..
So, instead of:
$dbFactory = JDatabaseFactory::getInstance(); //which does nothing really
AND
$options = array(
'driver' => 'mysqli',
'host' => 'localhost',
'user' => 'root',
'password' => 'definitely not root because that would be crazy',
'database' => 'db_name',
'prefix' => 'xyz_');
$this->db = $dbFactory->getDriver('mysqli'
, $options);
If the following were done:
$options = array(
'driver' => 'mysqli',
'host' => 'localhost',
'user' => 'root',
'password' => 'definitely not root because that would be crazy',
'database' => 'db_name',
'prefix' => 'xyz_');
$this->db = JDatabaseFactory::getInstance('mysqli', $options);
Then, $this->db stored as a static instance can then be used for queries,
export, import, and iteration without having to create a new instance each
time.
Does that make any sense? It seems like a cleaner, easier to understand way
to create and reuse a connection to the database, keeping a single point of
entry, and being able to reuse the connection (or create a new one, if
desired.)