Skip to content

Commit

Permalink
设置修正
Browse files Browse the repository at this point in the history
  • Loading branch information
dxkite committed Nov 10, 2016
1 parent e1539b0 commit 2c70fce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/Query/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function exec():int;
public function values(array $values);
public function query(string $query, array $array=[]);
public function error();
public function erron():int;
public function erron():string;
// 是否链接成功
public function good() :bool;
// 事务系列
Expand Down
6 changes: 3 additions & 3 deletions core/Query/PdoMySQL_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ public function error()
}
return false;
}
public function erron():int
public function erron():string
{
if ($this->stmt) {
var_dump($this->stmt->errorCode());
return $this->stmt->errorCode();
}
return false;
Expand All @@ -103,10 +102,11 @@ protected function lazyQuery(string $query, array $array=[])
if ($this->database && $this->dbchange) {
if (self::$pdo->query('USE '.$this->database)) {
$this->dbchange=false;
$this->database=null;
} else {
die('Could not select database:'.$this->database);
}
} elseif (!is_null($this->database)) {
} elseif (is_null($this->database)) {
if (self::$pdo->query('USE '.conf('Database.dbname'))) {
$this->database=conf('Database.dbname');
} else {
Expand Down
16 changes: 8 additions & 8 deletions lib/Site/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public static function init()
} else {
return false;
}
foreach ($options as $option) {
self::$options[$option['name']] = $option['value'];
}
self::$options['powered'] = 'DxSite '.CORE_VERSION;
self::$options['poweredUrl'] = 'https://github.com/DXkite/DxSite/releases/latest';
return true;
}

Expand All @@ -52,7 +47,12 @@ public static function refresh():bool
{
$sql = 'SELECT * FROM `#{site_options}`';
$q = new Query($sql);
self::$options = $q->fetchAll();
$options = $q->fetchAll();
foreach ($options as $option) {
self::$options[$option['name']] = $option['value'];
}
self::$options['powered'] = 'DxSite '.CORE_VERSION;
self::$options['poweredUrl'] = 'https://github.com/DXkite/DxSite/releases/latest';
Cache::set('SiteOption', self::$options, 0);
return $q->erron() === 0;
}
Expand All @@ -62,10 +62,10 @@ public static function getSiteOptions()
$q = new Query($sql);
return $q->fetchAll();
}
public static function setOption(string $name,string $value)
public static function setOption(string $name, string $value)
{
$sql='UPDATE `#{site_options}` SET `value`=:value WHERE `name`=:name LIMIT 1;';
return (new Query($sql,['name'=>$name,'value'=>$value]))->exec();
return (new Query($sql, ['name'=>$name, 'value'=>$value]))->exec();
}
/**
* 魔术方法获取设置
Expand Down

0 comments on commit 2c70fce

Please sign in to comment.