getMessage())); } return $instance; } /** * Gets an exporter class object. * * @param string $name Name of the driver you want an exporter for. * @param JDatabaseDriver $db Optional JDatabaseDriver instance * * @return JDatabaseExporter An exporter object. * * @since 12.1 * @throws RuntimeException */ public function getExporter($name, JDatabaseDriver $db = null) { // Derive the class name from the driver. $class = 'JDatabaseExporter' . ucfirst(strtolower($name)); // Make sure we have an exporter class for this driver. if (!class_exists($class)) { // If it doesn't exist we are at an impasse so throw an exception. throw new RuntimeException('Database Exporter not found.'); } $o = new $class; if ($db instanceof JDatabaseDriver) { $o->setDbo($db); } return $o; } /** * Gets an importer class object. * * @param string $name Name of the driver you want an importer for. * @param JDatabaseDriver $db Optional JDatabaseDriver instance * * @return JDatabaseImporter An importer object. * * @since 12.1 * @throws RuntimeException */ public function getImporter($name, JDatabaseDriver $db = null) { // Derive the class name from the driver. $class = 'JDatabaseImporter' . ucfirst(strtolower($name)); // Make sure we have an importer class for this driver. if (!class_exists($class)) { // If it doesn't exist we are at an impasse so throw an exception. throw new RuntimeException('Database importer not found.'); } $o = new $class; if ($db instanceof JDatabaseDriver) { $o->setDbo($db); } return $o; } /** * Gets an instance of the factory object. * * @return JDatabaseFactory * * @since 12.1 */ public static function getInstance() { return self::$_instance ? self::$_instance : new JDatabaseFactory; } /** * Get the current query object or a new JDatabaseQuery object. * * @param string $name Name of the driver you want an query object for. * @param JDatabaseDriver $db Optional JDatabaseDriver instance * * @return JDatabaseQuery The current query object or a new object extending the JDatabaseQuery class. * * @since 12.1 * @throws RuntimeException */ public function getQuery($name, JDatabaseDriver $db = null) { // Derive the class name from the driver. $class = 'JDatabaseQuery' . ucfirst(strtolower($name)); // Make sure we have a query class for this driver. if (!class_exists($class)) { // If it doesn't exist we are at an impasse so throw an exception. throw new RuntimeException('Database Query class not found'); } return new $class($db); } /** * Gets an instance of a factory object to return on subsequent calls of getInstance. * * @param JDatabaseFactory $instance A JDatabaseFactory object. * * @return void * * @since 12.1 */ public static function setInstance(JDatabaseFactory $instance = null) { self::$_instance = $instance; } }