NukeViet\Cache\Memcacheds::db PHP Method

db() public method

public db ( mixed $sql, mixed $key, mixed $modname, mixed $lang = '' )
$sql mixed
$key mixed
$modname mixed
$lang mixed
    public function db($sql, $key, $modname, $lang = '')
    {
        $_rows = array();
        if (empty($sql)) {
            return $_rows;
        }
        if (empty($lang)) {
            $lang = $this->_Lang;
        }
        $cache_key = $modname . '_' . $lang . '_' . md5($sql . '_' . $this->_Cache_Prefix);
        if (!($_rows = $this->_Cache->get($cache_key))) {
            if (($result = $this->_Db->query($sql)) !== false) {
                $a = 0;
                while ($row = $result->fetch()) {
                    $key2 = (!empty($key) and isset($row[$key])) ? $row[$key] : $a;
                    $_rows[$key2] = $row;
                    ++$a;
                }
                $result->closeCursor();
                $this->_Cache->set($cache_key, $_rows);
            }
        }
        return $_rows;
    }