public function getAdapter() { if (isset($this->model)) { /** @var Model $class */ $class = $this->model; $class::getDbAdapter(); } return Db::getAdapter($this->source); }
protected function onPrepare($argv = null) { $this->adapter = Db::getAdapter($this->source); $this->prefix = trim($this->adapter->getConfiguration()['prefix'], ' -_.'); $this->tables = $this->adapter->getForge()->getDbTables(); if (!empty($this->namespace)) { $this->namespace = str_replace('/', '\\', trim($this->namespace, KE_PATH_NOISE)); } }
protected function onConstruct($argv = null) { $this->src = App::getApp()->src(); $this->adapter = Db::getAdapter($this->source); $this->className = str_replace('/', '\\', $this->className); list($this->namespace, $this->className) = parse_class($this->className); if (empty($this->tableName)) { $this->tableName = strtolower($this->className); } $this->tableName = Db::mkTableName($this->source, $this->className, $this->tableName); }
<?php /** * kephp development env config file. */ use Ke\Adm; use Ke\Utils\DocMen\DocMen; //DocMen::getInstance('doc')->setShowFile(true)->setGenerable(true)->setWithWiki(true); // Database config Adm\Db::define(['default' => ['adapter' => 'mysql', 'db' => '', 'user' => '', 'prefix' => '']]); // Cache config Adm\Cache::define(['default' => ['adapter' => 'redis']]);
/** * @return Adapter\Db\PdoMySQL|Adapter\DbAdapter * @throws \Exception */ public static function getDbAdapter() { return Db::getAdapter(static::$dbSource); }