/** * Get requested DB driver. * By default XML configured driver is return. * @param string $type * @return Driver */ public static function getDriver($type = null) { if (!self::$instance) { $config = XMLLoader::load(DB_FILE); if ($type == null) { $type = $config->driver; } $driver = $type . DRIVER; self::$instance = new $driver($config); } return self::$instance; }
/** * {@inheritdoc} */ public function restore(OutputInterface $output) { $driver = $this->storageRegistry->getService(); $iterator = new \DirectoryIterator($this->archivePath); $files = $this->filterFiles($iterator); $totalCount = count($files); $files = $this->filterExisting($driver, $files); $count = count($files); $output->writeln(sprintf('Restoring %s of %s suites.', $count, $totalCount)); foreach ($files as $index => $file) { $this->writeProgress($output, $index, $count, '.'); $document = new Document(); $document->load($file->getPathname()); $collection = $this->xmlDecoder->decode($document); $driver->store($collection); } $output->write(PHP_EOL); }
/** * Renvoie le driver de cache par défaut * * @return InterfaceCache */ public function getDefaultDriver() { return DriverFactory::create(self::$_cDefaultDriver); }
public function __construct($type) { $this->db = DriverFactory::getDriver(); $this->type = strtolower($type); }
/** * Rad\Database\Connection constructor * * @param string $name * @param string $driver * @param array $config */ public function __construct($name, $driver, array $config) { $config = $config + ['host' => 'localhost', 'database' => 'rad', 'username' => 'root', 'password' => '', 'options' => []]; $this->name = $name; $this->driver = DriverFactory::get($driver, $config); }
protected function getDriver($driver) { $factory = new DriverFactory(); $driver = $factory->get($driver, $this->config); return $driver; }
public static function setInstance($instanceName, $driver, $user, $pass, $dbName, $host = null) { $driver = DriverFactory::Create($driver, $user, $pass, $dbName, $host); $pdo = new \PDO($driver->getDsn(), $user, $pass); self::$inst[$instanceName] = new self($pdo); }