Реорганизовал его в метод, который возвращает вместо операторов else
private static function getSoldout() {
self::$cache = $cache = url::assetsPath() . '../cache/soldout_cache';
//check the cache
if (!file_exists($cache)) {
return self::query();
}
$cache_date = filectime($cache);
db::select('date_modified');
db::orderBy('date_modified DESC');
db::limit(1);
$mod_date = db::get('sc_module_products')->fetch(PDO::FETCH_ASSOC);
if (!$mod_date) {
return self::query();
}
$mod_date = strtotime('date_modified');
if ($cache_date < $mod_date) {
return self::query();
}
try {
//serve the cache
$soldout = filewriter::read($cache);
$soldout = unserialize($soldout);
return $soldout;
} catch (Exception $e) {
return self::query();
}
}
public static function fetch($content) {
products_library::init();
$soldout = self::getSoldout();
$data['items'] = $soldout; // print_r($items); exit;
$html = view::load('Product_Display', $data, true);
return $html;
}
Я не понимаю эту строку, есть ли там ошибка?
$mod_date = strtotime('date_modified');