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


PHP Manufacturer::existsInDatabase方法代码示例

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


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

示例1: manufacturerImportOne

    protected function manufacturerImportOne($info, $shop_is_feature_active, $regenerate, $force_ids, $validateOnly = false)
    {
        AdminImportController::setDefaultValues($info);
        if ($force_ids && isset($info['id']) && (int) $info['id']) {
            $manufacturer = new Manufacturer((int) $info['id']);
        } else {
            if (array_key_exists('id', $info) && (int) $info['id'] && Manufacturer::existsInDatabase((int) $info['id'], 'manufacturer')) {
                $manufacturer = new Manufacturer((int) $info['id']);
            } else {
                $manufacturer = new Manufacturer();
            }
        }
        AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $manufacturer);
        $res = false;
        if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
            if ($manufacturer->id && $manufacturer->manufacturerExists($manufacturer->id)) {
                $res = $validateOnly || $manufacturer->update();
            }
            $manufacturer->force_id = (bool) $force_ids;
            if (!$res) {
                $res = $validateOnly || $manufacturer->add();
            }
            //copying images of manufacturer
            if (!$validateOnly && isset($manufacturer->image) && !empty($manufacturer->image)) {
                if (!AdminImportController::copyImg($manufacturer->id, null, $manufacturer->image, 'manufacturers', !$regenerate)) {
                    $this->warnings[] = $manufacturer->image . ' ' . $this->trans('cannot be copied.', array(), 'Admin.Parameters.Notification');
                }
            }
            if (!$validateOnly && $res) {
                // Associate supplier to group shop
                if ($shop_is_feature_active && $manufacturer->shop) {
                    Db::getInstance()->execute('
						DELETE FROM ' . _DB_PREFIX_ . 'manufacturer_shop
						WHERE id_manufacturer = ' . (int) $manufacturer->id);
                    $manufacturer->shop = explode($this->multiple_value_separator, $manufacturer->shop);
                    $shops = array();
                    foreach ($manufacturer->shop as $shop) {
                        if (empty($shop)) {
                            continue;
                        }
                        $shop = trim($shop);
                        if (!is_numeric($shop)) {
                            $shop = ShopGroup::getIdByName($shop);
                        }
                        $shops[] = $shop;
                    }
                    $manufacturer->associateTo($shops);
                }
            }
        }
        if (!$res) {
            if (!$validateOnly) {
                $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
            }
            if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
            }
        }
    }
开发者ID:M03G,项目名称:PrestaShop,代码行数:59,代码来源:AdminImportController.php

示例2: manufacturerImport

 public function manufacturerImport()
 {
     $this->receiveTab();
     $handle = $this->openCsvFile();
     self::setLocale();
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) {
         if (Tools::getValue('convert')) {
             $line = $this->utf8_encode_array($line);
         }
         $info = self::getMaskedRow($line);
         self::setDefaultValues($info);
         if (array_key_exists('id', $info) && (int) $info['id'] && Manufacturer::existsInDatabase((int) $info['id'], 'manufacturer')) {
             $manufacturer = new Manufacturer((int) $info['id']);
         } else {
             $manufacturer = new Manufacturer();
         }
         self::array_walk($info, array('AdminImport', 'fillInfo'), $manufacturer);
         $res = false;
         if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
             if ($manufacturer->id && $manufacturer->manufacturerExists($manufacturer->id)) {
                 $res = $manufacturer->update();
             }
             if (!$res) {
                 $res = $manufacturer->add();
             }
         }
         if (!$res) {
             $this->_errors[] = mysql_error() . ' ' . $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
             $this->_errors[] = ($field_error !== true ? $field_error : '') . ($lang_field_error !== true ? $lang_field_error : '') . mysql_error();
         }
     }
     $this->closeCsvFile($handle);
 }
开发者ID:greench,项目名称:prestashop,代码行数:33,代码来源:AdminImport.php

示例3: manufacturerImport

    public function manufacturerImport()
    {
        $this->receiveTab();
        $handle = $this->openCsvFile();
        AdminImportController::setLocale();
        for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
            if (Tools::getValue('convert')) {
                $line = $this->utf8EncodeArray($line);
            }
            $info = AdminImportController::getMaskedRow($line);
            AdminImportController::setDefaultValues($info);
            if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) {
                $manufacturer = new Manufacturer((int) $info['id']);
            } else {
                if (array_key_exists('id', $info) && (int) $info['id'] && Manufacturer::existsInDatabase((int) $info['id'], 'manufacturer')) {
                    $manufacturer = new Manufacturer((int) $info['id']);
                } else {
                    $manufacturer = new Manufacturer();
                }
            }
            AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $manufacturer);
            $res = false;
            if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
                if ($manufacturer->id && $manufacturer->manufacturerExists($manufacturer->id)) {
                    $res = $manufacturer->update();
                }
                $manufacturer->force_id = (bool) Tools::getValue('forceIDs');
                if (!$res) {
                    $res = $manufacturer->add();
                }
                //copying images of manufacturer
                if (isset($manufacturer->image) && !empty($manufacturer->image)) {
                    if (!AdminImportController::copyImg($manufacturer->id, null, $manufacturer->image, 'manufacturers', !Tools::getValue('regenerate'))) {
                        $this->warnings[] = $manufacturer->image . ' ' . Tools::displayError('cannot be copied.');
                    }
                }
                if ($res) {
                    // Associate supplier to group shop
                    if (Shop::isFeatureActive() && $manufacturer->shop) {
                        Db::getInstance()->execute('
							DELETE FROM ' . _DB_PREFIX_ . 'manufacturer_shop
							WHERE id_manufacturer = ' . (int) $manufacturer->id);
                        $manufacturer->shop = explode($this->multiple_value_separator, $manufacturer->shop);
                        $shops = array();
                        foreach ($manufacturer->shop as $shop) {
                            if (empty($shop)) {
                                continue;
                            }
                            $shop = trim($shop);
                            if (!is_numeric($shop)) {
                                $shop = ShopGroup::getIdByName($shop);
                            }
                            $shops[] = $shop;
                        }
                        $manufacturer->associateTo($shops);
                    }
                }
            }
            if (!$res) {
                $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
            }
        }
        $this->closeCsvFile($handle);
    }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:65,代码来源:AdminImportController.php


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