示例#1
0
 /**
  * DB Auth.
  *
  * @param array  $params
  * @param string $basePath
  */
 public function __construct($params, $basePath)
 {
     parent::__construct($basePath);
     $params = $params['mysql'];
     $this->allDatabases = $params['all_databases'];
     $this->database = $params['database'];
     $this->auth = '';
     if ($this->allDatabases) {
         $this->database = '--all-databases';
         $this->fileName = 'all-databases.sql';
     } else {
         $this->fileName = $this->database . '.sql';
     }
     if (isset($params['ignore_tables'])) {
         foreach ($params['ignore_tables'] as $ignoreTable) {
             if ($this->allDatabases) {
                 if (false === strpos($ignoreTable, '.')) {
                     throw new \LogicException('When dumping all databases both database and table must be specified when ignoring table');
                 }
                 $this->ignoreTables .= sprintf('--ignore-table=%s ', $ignoreTable);
             } else {
                 $this->ignoreTables .= sprintf('--ignore-table=%s.%s ', $this->database, $ignoreTable);
             }
         }
     }
     /* if user is set, we add authentification */
     if ($params['db_user']) {
         $this->auth = sprintf('-u%s', $params['db_user']);
         if ($params['db_password']) {
             $this->auth = sprintf("--host='%s' --port='%d' --user='******' --password='******'", $params['db_host'], $params['db_port'], $params['db_user'], $params['db_password']);
         }
     }
 }
示例#2
0
 function __construct(DatabaseSetting $db)
 {
     parent::__construct($db);
     if ($db->Username and $db->Username != "") {
         $this->DB = new \PDO("mysql:dbname={$db->DatabaseName};host={$db->Host};", $db->Username, $db->Password);
         $this->DB->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
         $this->Initialize($db->DatabaseName);
     } else {
         $this->DB = null;
     }
     //this is mandatory for no-database jFramework
     $this->m_databasename = $db->DatabaseName;
 }
示例#3
0
 function __construct(DatabaseSetting $db)
 {
     parent::__construct($db);
     if ($db->Username and $db->Username != "") {
         $File = "{$db->DatabaseName}";
         $this->DB = new \PDO("sqlite::memory:");
         $this->DB->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $this->Initialize($db->DatabaseName);
         // 			if (! is_writable ( $File ) && (! defined ( "jf_DB_ReadOnly" ) or ! constant ( "jf_DB_ReadOnly" ))) trigger_error ( "PDO_SQLite : database file not writable. Set read-only or grant write access to database file." );
         // 			if (! is_writable(constant ( "jf_DB_SQLite_Folder" )) && (!defined( "jf_DB_ReadOnly" ) or ! constant ( "jf_DB_ReadOnly" ))) trigger_error("PDO_SQLite : the folder containing the database should have full permissions, or set connection to read-only.");
     } else {
         $this->DB = null;
     }
     //this is mandatory for no-database jFramework
     $this->m_databasename = $db->DatabaseName;
 }
示例#4
0
 /**
  * DB Auth
  *
  * @param string $host
  * @param int    $port
  * @param string $database
  * @param string $user
  * @param string $password
  * @param string $basePath
  */
 public function __construct($host, $port, $database, $user, $password, $basePath)
 {
     parent::__construct($basePath);
     $this->database = $database;
     $this->auth = '';
     $this->authPrefix = '';
     $this->fileName = $this->database . '.sql';
     if ($password) {
         $this->authPrefix = sprintf('export PGPASSWORD="******" && ', $password);
     }
     if ($user) {
         $this->auth = sprintf('--username "%s" ', $user);
     }
     //TODO: pg_dump options support
     $this->auth .= sprintf('--host %s --port %d --format plain --encoding UTF8', $host, $port);
 }
示例#5
0
 /**
  * DB Auth.
  *
  * @param array  $params
  * @param string $basePath
  */
 public function __construct($params, $basePath)
 {
     parent::__construct($basePath);
     $params = $params['postgresql'];
     $this->database = $params['database'];
     $this->auth = '';
     $this->authPrefix = '';
     $this->fileName = $this->database . '.sql';
     if ($params['db_password']) {
         $this->authPrefix = sprintf('export PGPASSWORD="******" && ', $params['db_password']);
     }
     if ($params['db_user']) {
         $this->auth = sprintf('--username "%s" ', $params['db_user']);
     }
     //TODO: pg_dump options support
     $this->auth .= sprintf('--host %s --port %d --format plain --encoding UTF8', $params['db_host'], $params['db_port']);
 }
示例#6
0
 /**
  * DB Auth
  *
  * @param bool   $allDatabases
  * @param string $host
  * @param int    $port
  * @param string $database
  * @param string $user
  * @param string $password
  * @param string $basePath
  */
 public function __construct($allDatabases, $host, $port, $database, $user, $password, $basePath)
 {
     parent::__construct($basePath);
     $this->allDatabases = $allDatabases;
     $this->database = $database;
     $this->auth = '';
     if ($this->allDatabases) {
         $this->database = '--all-databases';
         $this->fileName = 'all-databases.sql';
     } else {
         $this->fileName = $this->database . '.sql';
     }
     /* if user is set, we add authentification */
     if ($user) {
         $this->auth = sprintf('-u%s', $user);
         if ($password) {
             $this->auth = sprintf("--host='%s' --port='%d' --user='******' --password='******'", $host, $port, $user, $password);
         }
     }
 }
示例#7
0
 /**
  * DB Auth
  *
  * @param bool   $allDatabases
  * @param string $host
  * @param int    $port
  * @param string $database
  * @param string $user
  * @param string $password
  * @param string $basePath
  */
 public function __construct($allDatabases, $host, $port, $database, $user, $password, $basePath)
 {
     parent::__construct($basePath);
     $this->allDatabases = $allDatabases;
     $this->database = $database;
     $this->auth = '';
     if ($this->allDatabases) {
         $this->database = '';
     } else {
         $this->database = sprintf('--db %s', $this->database);
     }
     /* Setting hostname & port */
     $this->auth = sprintf('-h %s --port %d', $host, $port);
     /* if user is set, we add authentification */
     if ($user) {
         $this->auth = sprintf('-h %s --port %d -u %s', $host, $port, $user);
         if ($password) {
             $this->auth = sprintf('-h %s --port %d -u %s -p %s', $host, $port, $user, $password);
         }
     }
 }
示例#8
0
 /**
  * DB Auth.
  *
  * @param array  $params
  * @param string $basePath
  */
 public function __construct($params, $basePath)
 {
     parent::__construct($basePath);
     $params = $params['mongodb'];
     $this->database = $params['database'];
     $this->auth = '';
     if ($params['all_databases']) {
         $this->database = '';
     } else {
         $this->database = sprintf('--db %s', $this->database);
     }
     /* Setting hostname & port */
     $this->auth = sprintf('-h %s --port %d', $params['db_host'], $params['db_port']);
     /* if user is set, we add authentification */
     if ($params['db_user']) {
         $this->auth = sprintf('-h %s --port %d -u %s', $params['db_host'], $params['db_port'], $params['db_user']);
         if ($params['db_password']) {
             $this->auth = sprintf('-h %s --port %d -u %s -p %s', $params['db_host'], $params['db_port'], $params['db_user'], $params['db_password']);
         }
     }
 }
示例#9
0
 /**
  * DB Auth.
  *
  * @param array  $params
  * @param string $basePath
  */
 public function __construct($params, $basePath)
 {
     parent::__construct($basePath);
     $params = $params['mysql'];
     $this->allDatabases = $params['all_databases'];
     $this->database = $params['database'];
     $this->auth = '';
     if ($this->allDatabases) {
         $this->database = '--all-databases';
         $this->fileName = 'all-databases.sql';
     } else {
         $this->fileName = $this->database . '.sql';
     }
     /* if user is set, we add authentification */
     if ($params['db_user']) {
         $this->auth = sprintf('-u%s', $params['db_user']);
         if ($params['db_password']) {
             $this->auth = sprintf("--host='%s' --port='%d' --user='******' --password='******'", $params['db_host'], $params['db_port'], $params['db_user'], $params['db_password']);
         }
     }
 }
示例#10
0
 function __construct(DatabaseSetting $db)
 {
     parent::__construct($db);
     if ($db->Username && $db->Username != "") {
         $this->Connection = new \mysqli($db->Host, $db->Username, $db->Password);
         if (!$this->Connection->select_db($db->DatabaseName)) {
             $this->SQL("CREATE DATABASE `{$db->DatabaseName}` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin");
             if (!($res = $this->Connection->select_db($db->DatabaseName))) {
                 throw new \Exception("Can not initialize database.");
             }
             $this->Initialize($db->DatabaseName);
         }
         if (mysqli_connect_errno()) {
             throw new \Exception("Unable to connect to MySQLi database: " . mysqli_connect_error());
         }
         if (isset($this->Charset)) {
             $this->Connection->set_charset($this->Charset);
         }
     } else {
         $this->Connection = null;
         //this is mandatory for no-database jFramework
     }
     $this->m_databasename = $db->DatabaseName;
 }