get() public method

get item from config
Since: 2.2.0
public get ( string $key = null ) : mixed
$key string key of the item
return mixed
示例#1
0
 /**
  * init the class
  *
  * @since 2.2.0
  *
  * @param Config $config instance of the config class
  */
 public static function init(Config $config)
 {
     self::$_config = $config;
     $dbType = $config->get('dbType');
     $dbHost = $config->get('dbHost');
     $dbName = $config->get('dbName');
     $dbUser = $config->get('dbUser');
     $dbPassword = $config->get('dbPassword');
     /* mysql and pgsql */
     if ($dbType === 'mysql' || $dbType === 'pgsql') {
         if ($dbType === 'mysql') {
             self::configure('connection_string', 'mysql:host=' . $dbHost . ';dbname=' . $dbName . ';charset=utf8');
         } else {
             self::configure('connection_string', 'pgsql:host=' . $dbHost . ';dbname=' . $dbName . ';options=--client_encoding=utf8');
         }
         /* username and password */
         self::configure(array('username' => $dbUser, 'password' => $dbPassword));
     }
     /* sqlite */
     if ($dbType === 'sqlite') {
         self::configure('sqlite:' . $dbHost);
     }
     /* general */
     self::configure(array('caching' => true, 'caching_auto_clear' => true, 'return_result_sets' => true));
 }
示例#2
0
 /**
  * testGetAll
  *
  * @since 2.2.0
  */
 public function testGetAll()
 {
     /* result */
     $result = Config::get();
     /* compare */
     $this->assertArrayHasKey('host', $result);
 }
示例#3
0
文件: Db.php 项目: ITw3/redaxscript
 /**
  * for table with prefix
  *
  * @since 2.2.0
  *
  * @param string $table name of the table
  * @param string $connection which connection to use
  *
  * @return Db
  */
 public static function forPrefixTable($table = null, $connection = self::DEFAULT_CONNECTION)
 {
     self::_setupDb($connection);
     return new self(Config::get('prefix') . $table, array(), $connection);
 }