Ejemplo n.º 1
0
 /**
  * 创建一个新的PDO链接
  *
  * @param  string  $dsn
  * @param  array   $config
  * @param  array   $options
  * @return \PDO
  */
 public function createConnection($dsn, array $config, array $options)
 {
     $username = Arr::get($config, 'username');
     $password = Arr::get($config, 'password');
     try {
         $pdo = new PDO($dsn, $username, $password, $options);
     } catch (Exception $e) {
         $pdo = $this->tryAgainIfCausedByLostConnection($e, $dsn, $username, $password, $options);
     }
     return $pdo;
 }
Ejemplo n.º 2
0
 /**
  * 获取链接配置文件
  *
  * @param  string  $name
  * @return array
  *
  * @throws \InvalidArgumentException
  */
 protected function getConfig($name)
 {
     $name = $name ?: $this->getDefaultConnection();
     $connections = $this->app['env']['redis']['connections'];
     if (is_null($config = Arr::get($connections, $name))) {
         throw new InvalidArgumentException("Redis [{$name}] not configured.");
     }
     return $config;
 }
Ejemplo n.º 3
0
 /**
  * 获取配置信息
  *
  * @param  string  $option
  * @return mixed
  */
 public function getConfig($option)
 {
     return Arr::get($this->config, $option);
 }
Ejemplo n.º 4
0
 /**
  * 获取指定配置
  *
  * @param  string  $key
  * @param  mixed   $default
  * @return mixed
  */
 public function get($key, $default = null)
 {
     return Arr::get($this->items, $key, $default);
 }
Ejemplo n.º 5
0
 /**
  * 完成保存进程后
  *
  * @param  array  $options
  * @return void
  */
 protected function finishSave(array $options)
 {
     $this->event('saved', false);
     $this->syncOriginal();
     if (Arr::get($options, 'touch', true)) {
         $this->touchOwners();
     }
 }
Ejemplo n.º 6
0
 /**
  * 获取一个宏定义(闭包)
  *
  * @param  string  $name
  * @return \Closure
  */
 public function getMacro($name)
 {
     return Arr::get($this->macros, $name);
 }
Ejemplo n.º 7
0
 /**
  * 使用 "逗点" 符号从深度巢状数组取回给定的值。
  *
  * @param  \ArrayAccess|array   $array
  * @param  string  $key
  * @param  mixed   $default
  * @return mixed
  */
 function array_get($array, $key, $default = null)
 {
     return Arr::get($array, $key, $default);
 }