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


PHP Combination::save方法代码示例

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


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

示例1: add

 function add()
 {
     if (!empty($this->data)) {
         $this->Browser->create();
         if ($this->Browser->save($this->data)) {
             App::import('Model', 'Operatingsystem');
             App::import('Model', 'Combination');
             $os = new Operatingsystem();
             $combination = new Combination();
             $os->recursive = 0;
             $all_os = $os->find('all');
             foreach ($all_os as $value) {
                 $data = array();
                 $data['Combination']['operatingsystem_id'] = $value['Operatingsystem']['id'];
                 $data['Combination']['browser_id'] = $this->Browser->id;
                 $combination->create();
                 $combination->save($data);
             }
             $this->Session->setFlash(__('The Browser has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The Browser could not be saved. Please, try again.', true));
         }
     }
 }
开发者ID:erlendfh,项目名称:Bromine,代码行数:25,代码来源:browsers_controller.php

示例2: testCombinationSuccess

 public function testCombinationSuccess()
 {
     $combination = new Combination();
     $combination->isPublic = true;
     $combination->protocol_id = 1;
     $combination->power_generator_id = 1;
     $combination->needle_id = 1;
     $this->assertTrue($combination->save());
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:9,代码来源:CombinationTest.php

示例3: add

 function add()
 {
     if (!empty($this->data)) {
         $this->Operatingsystem->create();
         if ($this->Operatingsystem->save($this->data)) {
             $browser = new Browser();
             $combination = new Combination();
             $browser->recursive = 0;
             $all_browser = $browser->find('all');
             foreach ($all_browser as $value) {
                 $data = array();
                 $data['Combination']['browser_id'] = $value['Browser']['id'];
                 $data['Combination']['operatingsystem_id'] = $this->Operatingsystem->id;
                 $combination->create();
                 $combination->save($data);
             }
             $this->Session->setFlash(__('The Operatingsystem has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The Operatingsystem could not be saved. Please, try again.', true));
         }
     }
 }
开发者ID:erlendfh,项目名称:Bromine,代码行数:23,代码来源:operatingsystems_controller.php

示例4: updateAttribute

 /**
  * Update a product attribute
  *
  * @param integer $id_product_attribute Product attribute id
  * @param float $wholesale_price Wholesale price
  * @param float $price Additional price
  * @param float $weight Additional weight
  * @param float $unit
  * @param float $ecotax Additional ecotax
  * @param integer $id_image Image id
  * @param string $reference Reference
  * @param string $ean13 Ean-13 barcode
  * @param int $default Default On
  * @param string $upc Upc barcode
  * @param string $minimal_quantity Minimal quantity
  * @return array Update result
  */
 public function updateAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = null, $available_date = null, $update_all_fields = true, array $id_shop_list = array())
 {
     $combination = new Combination($id_product_attribute);
     if (!$update_all_fields) {
         $combination->setFieldsToUpdate(array('price' => !is_null($price), 'wholesale_price' => !is_null($wholesale_price), 'ecotax' => !is_null($ecotax), 'weight' => !is_null($weight), 'unit_price_impact' => !is_null($unit), 'default_on' => !is_null($ecotax), 'minimal_quantity' => !is_null($minimal_quantity), 'available_date' => !is_null($available_date)));
     }
     $price = str_replace(',', '.', $price);
     $weight = str_replace(',', '.', $weight);
     $combination->price = (double) $price;
     $combination->wholesale_price = (double) $wholesale_price;
     $combination->ecotax = (double) $ecotax;
     $combination->weight = (double) $weight;
     $combination->unit_price_impact = (double) $unit;
     $combination->reference = pSQL($reference);
     $combination->location = pSQL($location);
     $combination->ean13 = pSQL($ean13);
     $combination->upc = pSQL($upc);
     $combination->default_on = (int) $default;
     $combination->minimal_quantity = (int) $minimal_quantity;
     $combination->available_date = $available_date ? pSQL($available_date) : '0000-00-00';
     if (count($id_shop_list)) {
         $combination->id_shop_list = $id_shop_list;
     }
     $combination->save();
     if (!empty($id_images)) {
         $combination->setImages($id_images);
     }
     Product::updateDefaultAttribute($this->id);
     Hook::exec('actionProductAttributeUpdate', array('id_product_attribute' => $id_product_attribute));
     return true;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:48,代码来源:Product.php

示例5: duplicateAttributes

    /**
     * Duplicate attributes when duplicating a product
     *
     * @param int $id_product_old Old product id
     * @param int $id_product_new New product id
     */
    public static function duplicateAttributes($id_product_old, $id_product_new)
    {
        $return = true;
        $combination_images = array();
        $result = Db::getInstance()->executeS('
		SELECT pa.*, product_attribute_shop.*
			FROM `' . _DB_PREFIX_ . 'product_attribute` pa
			' . Shop::addSqlAssociation('product_attribute', 'pa') . '
			WHERE pa.`id_product` = ' . (int) $id_product_old);
        $combinations = array();
        foreach ($result as $row) {
            $id_product_attribute_old = (int) $row['id_product_attribute'];
            if (!isset($combinations[$id_product_attribute_old])) {
                $id_combination = null;
                $id_shop = null;
                $result2 = Db::getInstance()->executeS('
				SELECT *
				FROM `' . _DB_PREFIX_ . 'product_attribute_combination`
					WHERE `id_product_attribute` = ' . $id_product_attribute_old);
            } else {
                $id_combination = (int) $combinations[$id_product_attribute_old];
                $id_shop = (int) $row['id_shop'];
                $context_old = Shop::getContext();
                $context_shop_id_old = Shop::getContextShopID();
                Shop::setContext(Shop::CONTEXT_SHOP, $id_shop);
            }
            $row['id_product'] = $id_product_new;
            unset($row['id_product_attribute']);
            $combination = new Combination($id_combination, null, $id_shop);
            foreach ($row as $k => $v) {
                $combination->{$k} = $v;
            }
            $return &= $combination->save();
            $id_product_attribute_new = (int) $combination->id;
            if ($result_images = Product::_getAttributeImageAssociations($id_product_attribute_old)) {
                $combination_images['old'][$id_product_attribute_old] = $result_images;
                $combination_images['new'][$id_product_attribute_new] = $result_images;
            }
            if (!isset($combinations[$id_product_attribute_old])) {
                $combinations[$id_product_attribute_old] = (int) $id_product_attribute_new;
                foreach ($result2 as $row2) {
                    $row2['id_product_attribute'] = $id_product_attribute_new;
                    $return &= Db::getInstance()->insert('product_attribute_combination', $row2);
                }
            } else {
                Shop::setContext($context_old, $context_shop_id_old);
            }
            //Copy suppliers
            $result3 = Db::getInstance()->executeS('
			SELECT *
			FROM `' . _DB_PREFIX_ . 'product_supplier`
			WHERE `id_product_attribute` = ' . (int) $id_product_attribute_old . '
			AND `id_product` = ' . (int) $id_product_old);
            foreach ($result3 as $row3) {
                unset($row3['id_product_supplier']);
                $row3['id_product'] = $id_product_new;
                $row3['id_product_attribute'] = $id_product_attribute_new;
                $return &= Db::getInstance()->insert('product_supplier', $row3);
            }
        }
        $impacts = self::getAttributesImpacts($id_product_old);
        if (is_array($impacts) && count($impacts)) {
            $impact_sql = 'INSERT INTO `' . _DB_PREFIX_ . 'attribute_impact` (`id_product`, `id_attribute`, `weight`, `price`) VALUES ';
            foreach ($impacts as $id_attribute => $impact) {
                $impact_sql .= '(' . (int) $id_product_new . ', ' . (int) $id_attribute . ', ' . (double) $impacts[$id_attribute]['weight'] . ', ' . (double) $impacts[$id_attribute]['price'] . '),';
            }
            $impact_sql = substr_replace($impact_sql, '', -1);
            $impact_sql .= ' ON DUPLICATE KEY UPDATE `price` = VALUES(price), `weight` = VALUES(weight)';
            Db::getInstance()->execute($impact_sql);
        }
        return !$return ? false : $combination_images;
    }
开发者ID:yewed,项目名称:share,代码行数:78,代码来源:Product.php

示例6: duplicateAttributes

    /**
     * Duplicate attributes when duplicating a product
     *
     * @param integer $id_product_old Old product id
     * @param integer $id_product_new New product id
     */
    public static function duplicateAttributes($id_product_old, $id_product_new)
    {
        $return = true;
        $combination_images = array();
        $result = Db::getInstance()->executeS('
		SELECT pa.*, product_attribute_shop.*
			FROM `' . _DB_PREFIX_ . 'product_attribute` pa
			' . Shop::addSqlAssociation('product_attribute', 'pa') . '
			WHERE pa.`id_product` = ' . (int) $id_product_old);
        $combinations = array();
        foreach ($result as $row) {
            $id_product_attribute_old = (int) $row['id_product_attribute'];
            if (!isset($combinations[$id_product_attribute_old])) {
                $id_combination = null;
                $id_shop = null;
                $result2 = Db::getInstance()->executeS('
				SELECT *
				FROM `' . _DB_PREFIX_ . 'product_attribute_combination`
					WHERE `id_product_attribute` = ' . $id_product_attribute_old);
            } else {
                $id_combination = (int) $combinations[$id_product_attribute_old];
                $id_shop = (int) $row['id_shop'];
                $context_old = Shop::getContext();
                $context_shop_id_old = Shop::getContextShopID();
                Shop::setContext(Shop::CONTEXT_SHOP, $id_shop);
            }
            $row['id_product'] = $id_product_new;
            unset($row['id_product_attribute']);
            $combination = new Combination($id_combination, null, $id_shop);
            foreach ($row as $k => $v) {
                $combination->{$k} = $v;
            }
            $return &= $combination->save();
            $id_product_attribute_new = (int) $combination->id;
            if ($result_images = Product::_getAttributeImageAssociations($id_product_attribute_old)) {
                $combination_images['old'][$id_product_attribute_old] = $result_images;
                $combination_images['new'][$id_product_attribute_new] = $result_images;
            }
            if (!isset($combinations[$id_product_attribute_old])) {
                $combinations[$id_product_attribute_old] = (int) $id_product_attribute_new;
                foreach ($result2 as $row2) {
                    $row2['id_product_attribute'] = $id_product_attribute_new;
                    $return &= Db::getInstance()->insert('product_attribute_combination', $row2);
                }
            } else {
                Shop::setContext($context_old, $context_shop_id_old);
            }
        }
        return !$return ? false : $combination_images;
    }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:56,代码来源:Product.php

示例7: ErpProductSupplier

         if ((int) $nbProducts['nb_products'] > 0) {
             $product_supplier = new ErpProductSupplier($nbProducts['id_product_supplier']);
             $product_supplier->product_supplier_price_te = $wholesale_price;
             $product_supplier->save();
         }
         /* If not global update of the product in any case */
         /*  Product */
         if ($id_product_attribute == '0') {
             $product = new Product($id_product);
             $product->wholesale_price = $wholesale_price;
             $product->save();
         } else {
             $combination = new Combination($id_product_attribute);
             $combination->id_product = $id_product;
             $combination->wholesale_price = $wholesale_price;
             $combination->save();
         }
         $update = DB::getInstance(_PS_USE_SQL_SLAVE_)->execute($query);
         echo $update;
     }
     break;
     /*  update delivery or cancel delivery  */
 /*  update delivery or cancel delivery  */
 case 'receipt_update':
 case 'receipt_cancel':
     $is_canceled = Tools::getValue('action') == 'receipt_update' ? 0 : 1;
     /*  update table ps_supply_order_receipt_history */
     $supply_order_receipt_history = new SupplyOrderReceiptHistory();
     $supply_order_receipt_history->id_supply_order_receipt_history = (int) Tools::getValue('id_supply_order_receipt_history');
     $supply_order_receipt_history->id = (int) Tools::getValue('id_supply_order_receipt_history');
     $supply_order_receipt_history->id_supply_order_detail = Tools::getValue('id_supply_order_detail');
开发者ID:prestamodule,项目名称:erpillicopresta,代码行数:31,代码来源:ajax.php

示例8: Material

$mat_1->belongs_to($company);
$mat_1->name = 'Skóra';
$mat_1->save();
$mat_2 = new Material();
$mat_2->belongs_to($company);
$mat_2->name = 'Drewno brzozowe';
$mat_2->save();
/** 1.6. Check if materials successfully created */
debug($mat_1->load());
debug($mat_2->load());
/** 1.7. Create a new material combination */
$comb = new Combination();
$comb->belongs_to($product);
$comb->has_multiple($mat_1, $mat_2);
$comb->price = '12.34';
$comb->save();
/** 1.8. Check if combination successfully created */
debug($comb->load());
/*
CREATE TABLE `product` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `company_id` int(10) unsigned NOT NULL,
  `name` text collate utf8_polish_ci NOT NULL,
  `elem_1` text collate utf8_polish_ci NOT NULL,
  `elem_2` text collate utf8_polish_ci NOT NULL,
  `elem_3` text collate utf8_polish_ci NOT NULL,
  `elem_4` text collate utf8_polish_ci NOT NULL,
  PRIMARY KEY  (`id`)
);
CREATE TABLE `combination` (
  `id` int(10) unsigned NOT NULL auto_increment,
开发者ID:laiello,项目名称:php-garden,代码行数:31,代码来源:item.docs.php


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