Cml\Db\MySql\Pdo::get PHP Метод

get() публичный Метод

根据key取出数据
public get ( string $key, boolean $and = true, boolean | string $useMaster = false, null | string $tablePrefix = null ) : array
$key string get('user-uid-123');
$and boolean 多个条件之间是否为and true为and false为or
$useMaster boolean | string 是否使用主库 默认读取从库 此选项为字符串时为表前缀$tablePrefix
$tablePrefix null | string 表前缀
Результат array
    public function get($key, $and = true, $useMaster = false, $tablePrefix = null)
    {
        if (is_string($useMaster) && is_null($tablePrefix)) {
            $tablePrefix = $useMaster;
            $useMaster = false;
        }
        is_null($tablePrefix) && ($tablePrefix = $this->tablePrefix);
        list($tableName, $condition) = $this->parseKey($key, $and);
        $tableName = $tablePrefix . $tableName;
        $sql = "SELECT * FROM {$tableName} WHERE {$condition} LIMIT 0, 1000";
        $cacheKey = md5($sql . json_encode($this->bindParams)) . $this->getCacheVer($tableName);
        $return = Model::getInstance()->cache()->get($cacheKey);
        if ($return === false) {
            //cache中不存在这条记录
            $stmt = $this->prepare($sql, $useMaster ? $this->wlink : $this->rlink);
            $this->execute($stmt);
            $return = $stmt->fetchAll(\PDO::FETCH_ASSOC);
            Model::getInstance()->cache()->set($cacheKey, $return, $this->conf['cache_expire']);
        } else {
            if (Cml::$debug) {
                $this->currentSql = $sql;
                $this->debugLogSql(Debug::SQL_TYPE_FROM_CACHE);
                $this->currentSql = '';
            }
            $this->clearBindParams();
        }
        return $return;
    }