Пример #1
0
 /**
  * Create a datasource representing a new user and database
  *
  * @param string $hint an advisory string; ideally included in $db/$user
  * @return Datasource;
  */
 public function createDatasource($hint)
 {
     $pass = \Amp\Util\StringUtil::createRandom(16);
     $user = \Amp\Util\StringUtil::createHintedRandom($hint, 16, 5, 'abcdefghijklmnopqrstuvwxyz0123456789');
     $datasource = new Datasource();
     $datasource->setDriver($this->adminDatasource->getDriver());
     $datasource->setHost($this->adminDatasource->getHost());
     $datasource->setPort($this->adminDatasource->getPort());
     $datasource->setSocketPath($this->adminDatasource->getSocketPath());
     $datasource->setUsername($user);
     $datasource->setPassword($pass);
     $datasource->setDatabase($user);
     return $datasource;
 }
Пример #2
0
 public function createDatasource($hint)
 {
     if (!$this->isRunning()) {
         $this->init();
     }
     $pass = \Amp\Util\String::createRandom(16);
     $user = \Amp\Util\String::createHintedRandom($hint, 16, 5, 'abcdefghijklmnopqrstuvwxyz0123456789');
     $datasource = new Datasource();
     $datasource->setDriver($this->adminDatasource->getDriver());
     $datasource->setHost('127.0.0.1');
     $datasource->setPort($this->port);
     $datasource->setSocketPath($this->mysql_socket_path);
     $datasource->setUsername($user);
     $datasource->setPassword($pass);
     $datasource->setDatabase($user);
     return $datasource;
 }