mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 23:55:35 +08:00
update to 1.2 version
Generate systemd script Default info_level set to 2 Modify & add some comment for Example module Brand new Console Add daemon command argument Add #OnTick annotation Add ZMRobot API class
This commit is contained in:
@@ -5,6 +5,7 @@ namespace ZM\DB;
|
||||
|
||||
|
||||
use Framework\Console;
|
||||
use ZM\Exception\DbException;
|
||||
|
||||
class SelectBody
|
||||
{
|
||||
@@ -23,8 +24,16 @@ class SelectBody
|
||||
$this->select_thing = $select_thing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
* @throws DbException
|
||||
*/
|
||||
public function get() { return $this->fetchAll(); }
|
||||
|
||||
/**
|
||||
* @return null
|
||||
* @throws DbException
|
||||
*/
|
||||
public function fetchAll() {
|
||||
if ($this->table->isCacheEnabled()) {
|
||||
$rr = md5(implode(",", $this->select_thing) . serialize($this->where_thing));
|
||||
@@ -40,10 +49,19 @@ class SelectBody
|
||||
return $this->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
* @throws DbException
|
||||
*/
|
||||
public function fetchFirst() {
|
||||
return $this->fetchAll()[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $key
|
||||
* @return mixed|null
|
||||
* @throws DbException
|
||||
*/
|
||||
public function value($key = null) {
|
||||
$r = $this->fetchFirst();
|
||||
if ($r === null) return null;
|
||||
@@ -52,6 +70,9 @@ class SelectBody
|
||||
else return $r[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DbException
|
||||
*/
|
||||
public function execute() {
|
||||
$str = $this->queryPrepare();
|
||||
$this->result = DB::rawQuery($str[0], $str[1]);
|
||||
|
||||
Reference in New Issue
Block a user