Skip to content

Commit

Permalink
changed getDb()
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Jan 23, 2017
1 parent a766a44 commit 1cd3d7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace hiqdev\hiart;

use Closure;
use Yii;
use hiqdev\hiart\stream\Request;
use yii\base\Component;
use yii\base\InvalidParamException;
Expand All @@ -36,6 +37,8 @@ abstract class AbstractConnection extends Component

public $activeQueryClass = ActiveQuery::class;

public static $dbname = 'hiart';

public $name = 'hiart';

public $userAgent = 'HiArt/0.x';
Expand Down Expand Up @@ -74,6 +77,11 @@ abstract class AbstractConnection extends Component
*/
protected $_errorChecker;

public static function getDb($dbname = null)
{
return Yii::$app->get($dbname ?: static::$dbname);
}

public function setAuth($auth)
{
$this->_auth = $auth;
Expand Down
4 changes: 2 additions & 2 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace hiqdev\hiart;

use Yii;
use hiqdev\hiart\AbstractConnection;
use yii\base\InvalidConfigException;
use yii\base\NotSupportedException;
use yii\db\ActiveQueryInterface;
Expand All @@ -30,7 +30,7 @@ class ActiveRecord extends BaseActiveRecord
*/
public static function getDb()
{
return Yii::$app->get('hiart');
return AbstractConnection::getDb();
}

/**
Expand Down

0 comments on commit 1cd3d7b

Please sign in to comment.