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


PHP Products::insert方法代码示例

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


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

示例1: saveAction

 /**
  * Create/update a product record in the database
  */
 public function saveAction()
 {
     $productsTable = new Products();
     $form = $this->getForm();
     if ($form->isValid($_POST)) {
         $values = $form->getValues();
         $id = $this->_hasParam('id') ? $this->_getParam('id') : null;
         unset($values['product_id'], $values['submit']);
         if (isset($id) && $id != null) {
             $productsTable->update($values, array('product_id = ?' => $id));
         } else {
             $id = $productsTable->insert($values);
         }
         $this->_redirect('/products/view/id/' . $id);
     } else {
         echo $form;
     }
 }
开发者ID:carriercomm,项目名称:billing-6,代码行数:21,代码来源:ProductsController.php

示例2: basename

        $count = $count + 1;
        exit;
    }
    $upimage = "http://lions-php08.rhcloud.com/" . basename($_FILES["Pimage"]["name"]);
    if (is_uploaded_file($_FILES['Pimage']['tmp_name'])) {
        if (!move_uploaded_file($_FILES['Pimage']['tmp_name'], $upimage)) {
            echo "problem";
        } else {
            $imgs = $_FILES['Pimage']['name'];
            $img = "<img  width=75px , height=75px , src=" . $imgs . " > </img>";
            echo "done";
            //$copy_file.=$img;
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    if ($count == 0) {
        $Product = new Products();
        $Product->pname = $name_product;
        $Product->productPicture = "images/" . $_FILES["Pimage"]["name"];
        $Product->price = $price_product;
        $Product->available = '1';
        $Product->cid = $category;
        $Product->insert();
        header('Location:../allProducts.php');
    } else {
        echo $error;
    }
    ///////////////////// else of submit ////////////////////////
} else {
    echo "You much click on Submit";
}
开发者ID:smagdy,项目名称:PHPproject,代码行数:31,代码来源:addProductAdmin.php

示例3: trim

 /**
  *
  *
  * @access public
  */
 function add_save()
 {
     $product_url = get_post_value('product_url');
     $title_cn = get_post_value('title_cn');
     $title_th = get_post_value('title_th');
     $category_1 = get_post_value('category_1');
     $category_2 = get_post_value('category_2');
     $category_3 = get_post_value('category_3');
     $floor_1 = get_post_value('floor_1');
     $floor_2 = get_post_value('floor_2');
     $floor_3 = get_post_value('floor_3');
     $purchase_price = trim(get_post_value('purchase_price'));
     $sales_price = trim(get_post_value('sales_price'));
     $start_time = get_post_value('start_time');
     $end_time = get_post_value('end_time');
     $image_url = get_post_value('image_url');
     $product_url = get_post_value('product_url');
     $shop_id = get_post_value('shop_id');
     $shop = get_post_value('shop');
     $shop_url = get_post_value('shop_url');
     $preferential_price = get_post_value('preferential_price');
     $field = array('product_url' => trim($product_url), 'title_cn' => trim($title_cn), 'title_th' => trim($title_th), 'category_3_id' => trim($category_3), 'floor_3_id' => trim($floor_3), 'purchase_price' => intval($purchase_price), 'sales_price' => intval($sales_price), 'preferential_price' => intval($preferential_price), 'image_url' => trim($image_url), 'product_url' => trim($product_url), 'shop' => trim($shop), 'start_time' => $start_time, 'end_time' => $end_time, 'hits' => '0', 'buys' => '0', 'favorites' => '0', 'created' => date('Y-m-d H:i:s', time()), 'created_name' => '', 'upload_name' => '', 'status' => '10000', 'category_1_id' => $category_1);
     $m = new Products();
     $m->clear();
     $m->setTable('vcb_product');
     //设置表名
     $m->setField($field);
     //设置更新字段及值,(键值数组)
     $data = $m->insert();
     //插入数据
     if (!$data) {
         //插入数据是否成功。
         echo '<br>保存失败<br>';
     } else {
         echo '<br>保存成功,<a href="add1">继续添加</a>,<a href="index">返回</a><br>';
     }
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:42,代码来源:ProductsController.class.php

示例4: trim

 function add_sizesave()
 {
     $size = trim(get_post_value('size'));
     $sku = trim(get_post_value('sku'));
     $sku_name = trim(get_post_value('sku_name'));
     $pro_k_id = get_post_value('pro_k_id');
     //echo $pro_k_id;
     $ve = $this->verify_kind($pro_k_id);
     // var_dump($ve);
     if (empty($ve)) {
         header('Location:error.php');
     }
     //  $arr_size = explode(',', $size);
     var_dump(count($arr_size));
     //  for ($i = 0; $i < count($arr_size); $i++) {
     $m = new Products();
     $field = array('size' => $size, 'sku' => $sku, 'sku_name' => $sku_name, 'product_kind_id' => $pro_k_id);
     $m->clear();
     $m->setField($field);
     $m->setTable(' vcb_product_ksize ');
     $data = $m->insert();
     //}
     if (!empty($data)) {
         header('Location:add_size?id=' . $pro_k_id);
     }
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:26,代码来源:ProductsController2015312.class.php

示例5: Products

<?php

include 'product.php';
$product = new Products();
//$product['id'] = $_POST['id'];
$product['name'] = $_POST['name'];
$product['price'] = $_POST['price'];
$product['qty'] = $_POST['qty'];
$product['sale'] = $_POST['sale'];
$prod = $product->insert();
开发者ID:shroukelsayed,项目名称:php,代码行数:10,代码来源:insertProduct.php

示例6: strtotime

            $name = $_FILES['image3']['name'];
            $tmp_name = @$_FILES['image3']['tmp_name'];
            @move_uploaded_file($tmp_name, '../images/' . strtotime("now") . $name);
            $product->pic3 = strtotime("now") . $name;
        } else {
            $product->pic3 = NULL;
        }
        if (!empty($_FILES['image4']['name'])) {
            $name = $_FILES['image4']['name'];
            $tmp_name = @$_FILES['image4']['tmp_name'];
            @move_uploaded_file($tmp_name, '../images/' . strtotime("now") . $name);
            $product->pic4 = strtotime("now") . $name;
        } else {
            $product->pic4 = NULL;
        }
        @($prod = $product->insert());
    }
}
?>
	
            </div>
            <!-- /. PAGE INNER  -->
        </div>
        <!-- /. PAGE WRAPPER  -->
    </div>
    <!-- /. WRAPPER  -->
    <!-- JS Scripts-->
    <!-- jQuery Js -->
    <script src="assets/js/jquery-1.10.2.js"></script>
    <!-- Bootstrap Js -->
    <script src="assets/js/bootstrap.min.js"></script>
开发者ID:shroukelsayed,项目名称:php,代码行数:31,代码来源:productNames.php

示例7: addtaobaosave

 function addtaobaosave()
 {
     $product_url = get_post_value('product_url');
     $title_cn = get_post_value('title_cn');
     $title_th = get_post_value('title_th');
     $category_1 = get_post_value('category_1');
     $category_2 = get_post_value('category_2');
     $category_3 = get_post_value('category_3');
     $floor_1 = get_post_value('floor_1');
     $floor_2 = get_post_value('floor_2');
     $floor_3 = get_post_value('floor_3');
     $purchase_price = trim(get_post_value('purchase_price'));
     $sales_price = trim(get_post_value('sales_price'));
     $start_time = get_post_value('start_time');
     $end_time = get_post_value('end_time');
     $image_url = get_post_value('image_url');
     $product_url = get_post_value('product_url');
     $shop_id = get_post_value('shop_id');
     $shop = get_post_value('shop');
     $shop_url = get_post_value('shop_url');
     $preferential_price = get_post_value('preferential_price');
     $shop_img = get_post_value('shop_img');
     $type0 = get_post_value('type0');
     $type1 = get_post_value('type1');
     $type2 = get_post_value('type2');
     $location = get_post_value('location');
     $imgsrc = get_post_value('imgsrc');
     $imgsrc = explode('|', $imgsrc);
     $array_type0 = explode('|', $type0);
     $array_type1 = explode('|', $type1);
     $array_type2 = explode('|', $type2);
     $now = date('Y');
     $p_name = time() . ".png";
     $p_url_ = "Upload/Products/" . date('Y') . "/" . date('m') . "/" . date('d') . "/";
     $purl_ = "Products/" . date('Y') . "/" . date('m') . "/" . date('d') . "/";
     get_file($shop_img, $p_url_, $p_name);
     $field = array('product_url' => trim($product_url), 'title_cn' => trim($title_cn), 'title_th' => trim($title_th), 'category_1_cn' => trim($category_1), 'category_2_cn' => trim($category_2), 'category_3_cn' => trim($category_3), 'floor_3_id' => trim($floor_3), 'purchase_price' => intval($purchase_price), 'sales_price' => intval($sales_price), 'preferential_price' => intval($preferential_price), 'old_price' => intval($preferential_price), 'image_path' => $purl_ . $p_name, 'shop' => trim($shop), 'start_time' => $start_time, 'end_time' => $end_time, 'hits' => '0', 'buys' => '0', 'favorites' => '0', 'created' => date('Y-m-d H:i:s', time()), 'created_name' => '', 'upload_name' => '', 'status' => '10000');
     $m = new Products();
     $m->clear();
     $m->setTable('vcb_product');
     //设置表名
     $m->setField($field);
     //设置更新字段及值,(键值数组)
     $data1 = $m->insert();
     //插入数据
     $field = array('product_id');
     $m->clear();
     $m->setField($field);
     $m->setTable('vcb_product');
     $m->setWhere('image_path', '=', $purl_ . $p_name);
     $data = $m->select();
     $product_id = $data[0]['product_id'];
     //这部分得修改aa:aa01|bb:bb01|cc:cc01
     foreach ($array_type0 as $key => $type0) {
         foreach ($array_type1 as $type1) {
             foreach ($array_type2 as $type2) {
                 $sku_name_cn = "颜色:" . $type0 . "|尺码:" . $type1 . "|重量:5kg";
                 $field = array('product_id' => $product_id, 'sku_code' => 'aa:aa01|bb:bb01|cc:cc01', 'sku_name_cn' => $sku_name_cn, 'sku_name_th' => NULL, 'sku_name_en' => NULL, 'qty' => '100', 'sales_price' => '1000', 'old_price' => '800');
                 $m->clear();
                 $m->setTable('vcb_product_sku');
                 $m->setField($field);
                 $data2 = $m->insert();
             }
         }
     }
     //这部分得修改aa:aa01|bb:bb01|cc:cc01
     for ($i = 0; $i < 1; $i++) {
         get_file($shop_img, $p_url_, $p_name . $i);
         $field = array('product_id' => $product_id, 'imgShowPath' => $purl_ . $p_name, 'imgDetailPath' => $purl_ . $p_name);
         $m->clear();
         $m->setTable('vcb_product_img_detail');
         $m->setField($field);
         $data3 = $m->insert();
     }
     //插入数据是否成功。
     if ($data1 && $data2 && $data3) {
         echo '<br>保存成功,<a href="add1">继续添加</a>,<a href="index">返回</a><br>';
     } else {
         echo '<br>保存失败<br>';
     }
 }
开发者ID:koery,项目名称:Vcanbuy,代码行数:81,代码来源:ProductsController.class.php


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