当前位置: 首页>>代码示例>>PHP>>正文


PHP Shop::checkIdShopDefault方法代码示例

本文整理汇总了PHP中Shop::checkIdShopDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::checkIdShopDefault方法的具体用法?PHP Shop::checkIdShopDefault怎么用?PHP Shop::checkIdShopDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shop的用法示例。


在下文中一共展示了Shop::checkIdShopDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addShopAssociation

 public static function addShopAssociation($table, $alias, $context = null)
 {
     if (is_null($context)) {
         $context = Context::getContext();
     }
     $table_alias = $table . '_shop';
     if (strpos($table, '.') !== false) {
         list($table_alias, $table) = explode('.', $table);
     }
     if (!array_key_exists($table, self::$blog_shop_tables)) {
         return;
     }
     $sql = ' INNER JOIN ' . _DB_PREFIX_ . $table . '_shop ' . $table_alias . ' ON (' . $table_alias . '.id_' . $table . ' = ' . $alias . '.id_' . $table;
     if (isset($context->shop->id)) {
         $sql .= ' AND ' . $table_alias . '.id_shop = ' . (int) $context->shop->id;
     } elseif (Shop::checkIdShopDefault($table)) {
         $sql .= ' AND ' . $table_alias . '.id_shop = ' . $alias . '.id_shop_default';
     } else {
         $sql .= ' AND ' . $table_alias . '.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')';
     }
     $sql .= ')';
     return $sql;
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:23,代码来源:BlogShop.php

示例2: addSqlAssociation

    /**
     * Add an SQL JOIN in query between a table and its associated table in multishop
     *
     * @param string $table Table name (E.g. product, module, etc.)
     * @param string $alias Alias of table
     * @param bool $inner_join Use or not INNER JOIN
     * @param string $on
     * @return string
     */
    public static function addSqlAssociation($table, $alias, $inner_join = true, $on = null, $force_not_default = false)
    {
        $table_alias = $table . '_shop';
        if (strpos($table, '.') !== false) {
            list($table_alias, $table) = explode('.', $table);
        }
        $asso_table = Shop::getAssoTable($table);
        if ($asso_table === false || $asso_table['type'] != 'shop') {
            return;
        }
        $sql = ($inner_join ? ' INNER' : ' LEFT') . ' JOIN ' . _DB_PREFIX_ . $table . '_shop ' . $table_alias . '
		ON (' . $table_alias . '.id_' . $table . ' = ' . $alias . '.id_' . $table;
        if ((int) self::$context_id_shop) {
            $sql .= ' AND ' . $table_alias . '.id_shop = ' . (int) self::$context_id_shop;
        } elseif (Shop::checkIdShopDefault($table) && !$force_not_default) {
            $sql .= ' AND ' . $table_alias . '.id_shop = ' . $alias . '.id_shop_default';
        } else {
            $sql .= ' AND ' . $table_alias . '.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')';
        }
        $sql .= ($on ? ' AND ' . $on : '') . ')';
        return $sql;
    }
开发者ID:gks-stage,项目名称:prestashop,代码行数:31,代码来源:Shop.php

示例3: update

 /**
  * Updates the current object in the database
  *
  * @param bool $null_values
  *
  * @return bool
  * @throws PrestaShopDatabaseException
  * @throws PrestaShopException
  */
 public function update($null_values = false)
 {
     // @hook actionObject*UpdateBefore
     Hook::exec('actionObjectUpdateBefore', array('object' => $this));
     Hook::exec('actionObject' . get_class($this) . 'UpdateBefore', array('object' => $this));
     $this->clearCache();
     // Automatically fill dates
     if (array_key_exists('date_upd', $this)) {
         $this->date_upd = date('Y-m-d H:i:s');
         if (isset($this->update_fields) && is_array($this->update_fields) && count($this->update_fields)) {
             $this->update_fields['date_upd'] = true;
         }
     }
     // Automatically fill dates
     if (array_key_exists('date_add', $this) && $this->date_add == null) {
         $this->date_add = date('Y-m-d H:i:s');
         if (isset($this->update_fields) && is_array($this->update_fields) && count($this->update_fields)) {
             $this->update_fields['date_add'] = true;
         }
     }
     $id_shop_list = Shop::getContextListShopID();
     if (count($this->id_shop_list) > 0) {
         $id_shop_list = $this->id_shop_list;
     }
     if (Shop::checkIdShopDefault($this->def['table']) && !$this->id_shop_default) {
         $this->id_shop_default = in_array(Configuration::get('PS_SHOP_DEFAULT'), $id_shop_list) == true ? Configuration::get('PS_SHOP_DEFAULT') : min($id_shop_list);
     }
     // Database update
     if (!($result = Db::getInstance()->update($this->def['table'], $this->getFields(), '`' . pSQL($this->def['primary']) . '` = ' . (int) $this->id, 0, $null_values))) {
         return false;
     }
     // Database insertion for multishop fields related to the object
     if (Shop::isTableAssociated($this->def['table'])) {
         $fields = $this->getFieldsShop();
         $fields[$this->def['primary']] = (int) $this->id;
         if (is_array($this->update_fields)) {
             $update_fields = $this->update_fields;
             $this->update_fields = null;
             $all_fields = $this->getFieldsShop();
             $all_fields[$this->def['primary']] = (int) $this->id;
             $this->update_fields = $update_fields;
         } else {
             $all_fields = $fields;
         }
         foreach ($id_shop_list as $id_shop) {
             $fields['id_shop'] = (int) $id_shop;
             $all_fields['id_shop'] = (int) $id_shop;
             $where = $this->def['primary'] . ' = ' . (int) $this->id . ' AND id_shop = ' . (int) $id_shop;
             // A little explanation of what we do here : we want to create multishop entry when update is called, but
             // only if we are in a shop context (if we are in all context, we just want to update entries that alread exists)
             $shop_exists = Db::getInstance()->getValue('SELECT ' . $this->def['primary'] . ' FROM ' . _DB_PREFIX_ . $this->def['table'] . '_shop WHERE ' . $where);
             if ($shop_exists) {
                 $result &= Db::getInstance()->update($this->def['table'] . '_shop', $fields, $where, 0, $null_values);
             } elseif (Shop::getContext() == Shop::CONTEXT_SHOP) {
                 $result &= Db::getInstance()->insert($this->def['table'] . '_shop', $all_fields, $null_values);
             }
         }
     }
     // Database update for multilingual fields related to the object
     if (isset($this->def['multilang']) && $this->def['multilang']) {
         $fields = $this->getFieldsLang();
         if (is_array($fields)) {
             foreach ($fields as $field) {
                 foreach (array_keys($field) as $key) {
                     if (!Validate::isTableOrIdentifier($key)) {
                         throw new PrestaShopException('key ' . $key . ' is not a valid table or identifier');
                     }
                 }
                 // If this table is linked to multishop system, update / insert for all shops from context
                 if ($this->isLangMultishop()) {
                     $id_shop_list = Shop::getContextListShopID();
                     if (count($this->id_shop_list) > 0) {
                         $id_shop_list = $this->id_shop_list;
                     }
                     foreach ($id_shop_list as $id_shop) {
                         $field['id_shop'] = (int) $id_shop;
                         $where = pSQL($this->def['primary']) . ' = ' . (int) $this->id . ' AND id_lang = ' . (int) $field['id_lang'] . ' AND id_shop = ' . (int) $id_shop;
                         if (Db::getInstance()->getValue('SELECT COUNT(*) FROM ' . pSQL(_DB_PREFIX_ . $this->def['table']) . '_lang WHERE ' . $where)) {
                             $result &= Db::getInstance()->update($this->def['table'] . '_lang', $field, $where);
                         } else {
                             $result &= Db::getInstance()->insert($this->def['table'] . '_lang', $field);
                         }
                     }
                 } else {
                     $where = pSQL($this->def['primary']) . ' = ' . (int) $this->id . ' AND id_lang = ' . (int) $field['id_lang'];
                     if (Db::getInstance()->getValue('SELECT COUNT(*) FROM ' . pSQL(_DB_PREFIX_ . $this->def['table']) . '_lang WHERE ' . $where)) {
                         $result &= Db::getInstance()->update($this->def['table'] . '_lang', $field, $where);
                     } else {
                         $result &= Db::getInstance()->insert($this->def['table'] . '_lang', $field, $null_values);
                     }
                 }
//.........这里部分代码省略.........
开发者ID:jpodracky,项目名称:dogs,代码行数:101,代码来源:ObjectModel.php


注:本文中的Shop::checkIdShopDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。