Exemple #1
0
 public static function prepareEnvironment(ConnectionManagement $connection)
 {
     $database = $connection->getDatabase();
     $newConnection = new ConnectionManagement(str_replace("/{$database}", "/", $connection->getDbConnectionString()));
     $dbDataset = new DBDataset($newConnection->getDbConnectionString());
     $dbDataset->execSQL("CREATE SCHEMA IF NOT EXISTS `{$database}` DEFAULT CHARACTER SET utf8 ;");
 }
Exemple #2
0
 /**
  *
  * @param string $dbname
  * @param string $collection
  * @throws InvalidArgumentException
  */
 public function __construct($dbname, $collection)
 {
     $this->_connectionManagement = new ConnectionManagement($dbname);
     if ($this->_connectionManagement->getDriver() == "mongodb") {
         $this->_dbDriver = new MongoDBDriver($this->_connectionManagement, $collection);
     } else {
         throw new InvalidArgumentException("There is no '{$this->_connectionManagement->getDriver()}' NoSQL database");
     }
 }
Exemple #3
0
 /**
  * Each provider have your own model for pass parameter. This method define how each provider name define the parameters
  *
  * @param ConnectionManagement $connData
  * @return string
  */
 public static function getParamModel(ConnectionManagement $connData)
 {
     if ($connData->getExtraParam("parammodel") != "") {
         return $connData->getExtraParam("parammodel");
     } elseif ($connData->getDriver() == "sqlrelay") {
         return "?";
     } else {
         return ":_";
     }
 }
Exemple #4
0
 /**
  *
  * @param ConnectionManagement $connMngt
  * @return string
  */
 public static function getTnsString($connMngt)
 {
     $protocol = $connMngt->getExtraParam("protocol");
     $protocol = $protocol == "" ? 'TCP' : $protocol;
     $port = $connMngt->getPort();
     $port = $port == "" ? 1521 : $port;
     $svcName = $connMngt->getDatabase();
     $host = $connMngt->getServer();
     $tns = "(DESCRIPTION = " . "\t(ADDRESS = (PROTOCOL = {$protocol})(HOST = {$host})(PORT = {$port})) " . "\t\t(CONNECT_DATA = (SERVICE_NAME = {$svcName})) " . ")";
     return $tns;
 }
Exemple #5
0
 public static function factory(ConnectionManagement $connMngt)
 {
     if (!defined('PDO::ATTR_DRIVER_NAME')) {
         throw new NotAvailableException("Extension 'PDO' is not loaded");
     }
     if (!extension_loaded('pdo_' . strtolower($connMngt->getDriver()))) {
         throw new NotAvailableException("Extension 'pdo_" . strtolower($connMngt->getDriver()) . "' is not loaded");
     }
     $class = '\\ByJG\\AnyDataset\\Database\\Pdo' . ucfirst($connMngt->getDriver());
     if (!class_exists($class, true)) {
         return new DBPDODriver($connMngt, null, null, null);
     } else {
         return new $class($connMngt);
     }
 }
Exemple #6
0
 /**
  * Get a IDbFunctions class to execute Database specific operations.
  * @return DBFunctionsInterface
  */
 public function getDbFunctions()
 {
     if (is_null($this->_dbFunction)) {
         $dbFunc = "\\ByJG\\AnyDataset\\Database\\DB" . ucfirst($this->_connectionManagement->getDriver()) . "Functions";
         $this->_dbFunction = new $dbFunc();
     }
     return $this->_dbFunction;
 }
Exemple #7
0
 /**
  * Creates a new MongoDB connection. This class is managed from NoSqlDataset
  *
  * @param ConnectionManagement $connMngt
  * @param string $collection
  */
 public function __construct($connMngt, $collection)
 {
     $this->_connectionManagement = $connMngt;
     $hosts = $this->_connectionManagement->getServer();
     $port = $this->_connectionManagement->getPort() == '' ? 27017 : $this->_connectionManagement->getPort();
     $database = $this->_connectionManagement->getDatabase();
     $username = $this->_connectionManagement->getUsername();
     $password = $this->_connectionManagement->getPassword();
     if ($username != '' && $password != '') {
         $auth = array('username' => $username, 'password' => $password, 'connect' => 'true');
     } else {
         $auth = array('connect' => 'true');
     }
     $connecting_string = sprintf('mongodb://%s:%d', $hosts, $port);
     $this->_client = new MongoClient($connecting_string, $auth);
     $this->_db = new MongoDB($this->_client, $database);
     $this->setCollection($collection);
 }
Exemple #8
0
 protected function getCommandClassName()
 {
     return "\\ByJG\\DbMigration\\Commands\\" . ucfirst($this->_connection->getDriver()) . "Command";
 }
Exemple #9
0
 public function __construct(ConnectionManagement $connMngt)
 {
     $strcnn = $connMngt->getDriver() . ":" . $connMngt->getServer();
     parent::__construct($connMngt, $strcnn, [], []);
 }
Exemple #10
0
 public function __construct(ConnectionManagement $connMngt)
 {
     $strcnn = $connMngt->getDbConnectionString();
     $postOptions = [PDO::ATTR_EMULATE_PREPARES => true];
     parent::__construct($connMngt, $strcnn, [], $postOptions);
 }
Exemple #11
0
 public function __construct($connMngt)
 {
     $this->_connectionManagement = $connMngt;
     $this->_conn = sqlrcon_alloc($this->_connectionManagement->getServer(), $this->_connectionManagement->getPort(), $this->_connectionManagement->getExtraParam("unixsocket"), $this->_connectionManagement->getUsername(), $this->_connectionManagement->getPassword(), 0, 1);
     sqlrcon_autoCommitOn($this->_conn);
 }