Ejemplo n.º 1
0
 public function loadDefaultValues()
 {
     $db = \Yii::$app->getDb();
     $dsn = Dsn::parse($db->dsn);
     $this->hostname = $dsn->host;
     $this->database = $dsn->database;
     $this->username = $db->username;
     $this->password = $db->password;
 }
Ejemplo n.º 2
0
 public function loadDefaultValues()
 {
     $definitions = \Yii::$app->getComponents();
     if (isset($definitions["db"]) && isset($definitions["db"]['dsn'])) {
         $dsn = Dsn::parse($definitions["db"]['dsn']);
         $this->hostname = $dsn->host;
         $this->database = $dsn->database;
         $this->port = $dsn->port;
         $this->username = $definitions["db"]['username'];
         $this->password = $definitions["db"]['password'];
         $this->prefix = $definitions["db"]['tablePrefix'];
     }
 }
Ejemplo n.º 3
0
<?php

/* @var $exception \yii\base\Exception */
/* @var $dsn \fourteenmeister\helpers\Dsn */
$this->title = 'warning';
use fourteenmeister\extensions\SemanticUI\widgets\DetailView;
use fourteenmeister\helpers\Dsn;
$dsn = Dsn::parse(Yii::$app->db->dsn);
$data = ['driverName' => Yii::$app->db->driverName, 'host' => $dsn->getHost(), 'database' => $dsn->getDatabase(), 'port' => $dsn->getPort(), 'username' => Yii::$app->db->username, 'password' => Yii::$app->db->password, 'error' => $exception->getMessage()];
echo DetailView::widget(['model' => $data, 'template' => '<tr><td class="four wide">{label}</td><td>{value}</td></tr>', 'attributes' => ['driverName' => ['attribute' => 'driverName', 'label' => 'Наименование драйвера'], 'host' => ['attribute' => 'host', 'label' => 'Хост'], 'database' => ['attribute' => 'database', 'label' => 'Имя базы данных'], 'port' => ['attribute' => 'port', 'label' => 'Порт'], 'username' => ['attribute' => 'username', 'label' => 'Имя пользователя'], 'password' => ['attribute' => 'password', 'label' => 'Пароль'], 'error' => ['attribute' => 'error', 'label' => 'Описание ошибки', 'format' => 'raw']]]);
Ejemplo n.º 4
0
 public function init()
 {
     $this->dsn = str_replace("dbname=", "", $this->dsn);
     parent::init();
 }