本文整理汇总了PHP中Cache::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::find方法的具体用法?PHP Cache::find怎么用?PHP Cache::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCountries
public function getCountries($data = array())
{
$cache = 'countries.' . json_encode($data);
$return = Cache::find($cache);
if (is_array($return)) {
return $return;
}
$sql = "SELECT * FROM PREFIX_country";
$sort_data = array('name', 'iso_code_2', 'iso_code_3');
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY name";
}
if (isset($data['order']) && $data['order'] == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
}
$return = $this->fetchAll($sql);
Cache::set($cache, $return);
return $return;
}
示例2: getGeoZones
public function getGeoZones($data = array())
{
if ($data) {
$sql = "SELECT * FROM PREFIX_geo_zone";
$sort_data = array('name', 'description');
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY name";
}
if (isset($data['order']) && $data['order'] == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
}
return $this->fetchAll($sql);
} else {
$data = Cache::find('geo_zone');
if (!$data) {
$data = $this->fetchAll("SELECT * FROM PREFIX_geo_zone ORDER BY name ASC");
Cache::set('geo_zone', $data);
}
return $data;
}
}
示例3: getWeightClasses
public function getWeightClasses($data = array())
{
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int) $this->config->get('config_language_id') . "'";
$sort_data = array('title', 'unit', 'value');
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY title";
}
if (isset($data['order']) && $data['order'] == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
} else {
$weight_class_data = Cache::find('weight_class.' . (int) $this->config->get('language_id'));
if (!$weight_class_data) {
$weight_class_data = $this->fetchAll("SELECT * FROM PREFIX_weight_class wc\n LEFT JOIN PREFIX_weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id)\n WHERE wcd.language_id = '" . (int) $this->config->get('language_id') . "'");
Cache::set('weight_class.' . (int) $this->config->get('language_id'), $weight_class_data);
}
return $weight_class_data;
}
}
示例4: getExtensions
public function getExtensions($type)
{
$cache = Cache::find('extensions.' . $this->config->get('config_store_id'), $type);
if (!is_array($cache)) {
$cache = Database::fetchAll("SELECT * FROM PREFIX_extension WHERE `type` = :type", array('type' => $type));
Cache::set('extensions.' . $this->config->get('config_store_id'), $type, $cache);
}
return $cache;
}
示例5: getZonesByCountryId
public function getZonesByCountryId($country_id)
{
$zone_data = Cache::find('zone.' . (int) $country_id);
if (!$zone_data) {
$zone_data = $this->fetchAll("SELECT * FROM PREFIX_zone WHERE country_id = :id AND status = 1 ORDER BY name", array('id' => $country_id));
Cache::set('zone.' . (int) $country_id, $zone_data);
}
return $zone_data;
}
示例6: getStores
public function getStores($data = array())
{
$store_data = Cache::find('store');
if (!$store_data || !is_array($store_data) || empty($store_data)) {
$store_data = Database::fetchAll("SELECT * FROM PREFIX_store ORDER BY url");
Cache::set('store', $store_data);
}
return $store_data;
}
示例7: index
protected function index($setting)
{
$this->data['heading_title'] = Language::getVar('SUMO_PRODUCT_BESTSELLER');
$this->load->model('catalog/product');
$this->load->model('tool/image');
if ($this->registry->get('builder')) {
$this->data['settings'] = Cache::find('builder');
}
$this->data['products'] = array();
$results = $this->model_catalog_product->getBestSellerProducts($setting['limit']);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
$swapimages = $this->model_catalog_product->getProductImages($result['product_id']);
if ($swapimages) {
$swapimage = $this->model_tool_image->resize($swapimages[0]['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'), 'h');
} else {
$swapimage = false;
}
if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((double) $result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}
if ($result['reviews']) {
if ($result['reviews'] > 1) {
$reviews = Language::getVar('SUMO_PRODUCT_REVIEWS_PLURAL', $result['reviews']);
} else {
$reviews = Language::getVar('SUMO_PRODUCT_REVIEWS_SINGULAR');
}
} else {
$reviews = Language::getVar('SUMO_PRODUCT_REVIEWS_NONE');
}
$this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'thumb_swap' => $swapimage, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => $reviews, 'href' => $this->url->link('product/product', 'path=' . $result['category_id'] . '&product_id=' . $result['product_id']));
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/bestseller.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/bestseller.tpl';
} else {
$this->template = 'default/template/module/bestseller.tpl';
}
if (count($this->data['products'])) {
$this->render();
}
}
示例8: getBlogs
public function getBlogs()
{
$data = Cache::find('blogs');
if (count($data)) {
return $data;
}
$query = $this->fetchAll("SELECT * FROM PREFIX_blog i LEFT JOIN PREFIX_blog_description id ON (i.blog_id = id.blog_id) WHERE id.language_id = '" . (int) $this->config->get('language_id') . "' AND i.store_id = '" . (int) $this->config->get('store_id') . "' AND i.status = '1' AND i.publish_date < NOW() ORDER BY i.publish_date DESC");
Cache::set('blogs', $query);
return $query->rows;
}
示例9: getZonesByCountryId
public function getZonesByCountryId($country_id)
{
$cache = 'zones.' . $country_id;
$data = Cache::find($cache);
if (!is_array($data) || !count($data)) {
$data = $this->fetchAll("SELECT * FROM PREFIX_zone WHERE country_id = :id AND status = 1 ORDER BY name", array('id' => $country_id));
Cache::set($cache, $data);
}
return $data;
}
示例10: getDashboardItems
public function getDashboardItems()
{
$active = $this->getActiveMenu();
$return = Cache::find('adi_' . md5($active));
if (!is_array($return)) {
$return = Database::fetchAll("\n SELECT *\n FROM PREFIX_admin_menu\n WHERE parent_id = (SELECT menu_id FROM PREFIX_admin_menu WHERE url = :url)\n OR url = :url2\n ORDER BY sort_order ASC, parent_id ASC", array('url' => $active, 'url2' => $active));
Cache::set('admin_menu.adi_' . md5($active), $return);
}
return $return;
}
示例11: getOrderStatuses
public function getOrderStatuses($data = array())
{
$cache = 'order_status.' . $this->config->get('language_id');
$data = Cache::find($cache);
if (is_array($data) && count($data)) {
return $data;
}
$data = $this->fetchAll("SELECT order_status_id, name FROM PREFIX_order_status WHERE language_id = :id ORDER BY name", array('id' => $this->config->get('language_id')));
Cache::set($cache, $data);
return $data;
}
示例12: getCountries
public function getCountries()
{
$cache = 'countries';
$data = Cache::find($cache);
if (is_array($cache) && count($cache)) {
return $data;
}
$data = self::fetchAll("SELECT * FROM PREFIX_country WHERE status = 1 ORDER BY name ASC");
Cache::set($cache, $data);
return $data;
}
示例13: getTotalCategoriesByCategoryId
public function getTotalCategoriesByCategoryId($parent_id = 0)
{
$cacheFile = 'categories.totals-' . $parent_id . '-' . (int) $this->config->get('language-id') . '-' . (int) $this->config->get('store_id');
$cache = Cache::find($cacheFile);
if (is_array($cache) && count($cache)) {
return $cache;
}
$result = self::query("SELECT COUNT(*) AS total FROM PREFIX_category c LEFT JOIN PREFIX_category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int) $parent_id . "' AND c2s.store_id = '" . (int) $this->config->get('store_id') . "' AND c.status = '1'")->fetch();
Cache::set($cacheFile, $result);
return $result;
}
示例14: getLayout
public function getLayout($route)
{
$cacheFile = 'settings.layouts.' . $this->config->get('config_store_id');
$cache = Cache::find($cacheFile, $route);
if ($cache !== null) {
return $cache;
}
$fallback = explode('/', $route);
$result = Database::query("SELECT * FROM PREFIX_layout_route WHERE (:route LIKE CONCAT(route, '%') OR :fallback LIKE CONCAT(route, '%')) AND store_id = :store ORDER BY route DESC LIMIT 1", array('route' => $route, 'fallback' => $fallback[0] . '/', 'store' => $this->config->get('config_store_id')))->fetch();
Cache::set($cacheFile, $route, $result['layout_id']);
return $result['layout_id'];
}
示例15: __construct
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$lengths = Cache::find('lengths.' . $this->config->get('config_language_id'));
if (!is_array($lengths)) {
$lengths = Database::fetchAll("SELECT * FROM PREFIX_length_class AS lc LEFT JOIN PREFIX_length_class_description AS lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lcd.language_id = :lang", array('lang' => $this->config->get('config_language_id')));
Cache::set('lengths.' . $this->config->get('config_language_id'), $lengths);
}
foreach ($lengths as $result) {
$this->lengths[$result['length_class_id']] = array('length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}