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


PHP Items::create方法代码示例

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


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

示例1: create

 public function create()
 {
     if (!empty($_POST['itemid']) && !empty($_POST['itemname']) && !empty($_POST['qty'])) {
         $newItem = new Items();
         if (isset($_FILES['fupload']) && $_FILES['fupload']['error'] == 0) {
             //if file upload is set
             move_uploaded_file($_FILES['fupload']['tmp_name'], "public/uploads/" . basename($_FILES['fupload']['name']));
             $image = new Imageresize();
             // an instance of image resize object
             $image->load("public/uploads/" . basename($_FILES['fupload']['name']));
             //$image->image =;
             $image->resize(400, 400);
             $image->save("public/uploads/" . basename($_FILES['fupload']['name']));
             //this section is needed to get the extension for image type in renaming the image
             if ($_FILES['fupload']['type'] == "image/gif") {
                 $ext = ".gif";
             }
             if ($_FILES['fupload']['type'] == "image/png") {
                 $ext = ".png";
             }
             if ($_FILES['fupload']['type'] == "image/jpeg") {
                 $ext = ".jpeg";
             }
             if ($_FILES['fupload']['type'] == "image/pjpeg") {
                 $ext = ".jpeg";
             }
             if ($_FILES['fupload']['type'] == "image/gif") {
                 $ext = ".gif";
             }
             if ($_FILES['fupload']['type'] == "image/jpg") {
                 $ext = ".jpg";
             }
             $new_name = uniqid() . "_" . time() . $ext;
             //new name for the image
             rename("public/uploads/" . basename($_FILES['fupload']['name']), "public/uploads/" . $new_name);
             $photo = $new_name;
             $applicant->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $newItem->item_id = $_POST['itemid'];
         $newItem->item_name = $_POST['itemname'];
         $newItem->item_description = $_POST['descript'];
         $newItem->item_type = $_POST['ttype'];
         $newItem->item_cost = $_POST['cprice'];
         $newItem->item_quantity = $_POST['qty'];
         $newItem->item_isbn = $_POST['isbn'];
         $newItem->item_serial = $_POST['serial'];
         $newItem->item_dateadded = date("Y-m-d H:i:s");
         if ($newItem->create()) {
             return 1;
             //returns 1 on success
         } else {
             return 2;
             // returns 2 on insert error
         }
     } else {
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
开发者ID:runningjack,项目名称:RobertJohnson,代码行数:61,代码来源:stockitems_model.php

示例2: json_encode

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
// load the items class
require_once '../classes/concertClass.php';
$response = array('error' => true, 'message' => '');
if (isset($_POST['name'])) {
    $name = $_POST['name'];
    $items = new Items();
    // create the new item
    if ($data = $items->create($name)) {
        $response['error'] = false;
        $response['message'] = 'Items has been created';
        $response['item'] = $data;
    } else {
        $response['message'] = 'Could not create the new item';
    }
}
// request response in json format
echo json_encode($response);
开发者ID:JimmyC24,项目名称:proyecto-auditorio,代码行数:21,代码来源:create.php

示例3: create

 /**
  * @name create
  * @description create a new item
  * @param string $name
  * @return mixed
  */
 private function create($name)
 {
     $item = new Items();
     if ($data = $item->create($name)) {
         return $this->response($data, 'New item has been created', false);
     }
     return $this->response('', 'Could not create a new item', true);
 }
开发者ID:Kesymaru,项目名称:inventario,代码行数:14,代码来源:itemsController.php


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