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


PHP Item::setCategory方法代码示例

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


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

示例1: create

    public function create(Category $category, $name, $price, $stock, $image, $description)
    {
        $errors = array();
        $item = new Item($this->db);
        try {
            $item->setCategory($category);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setName($name);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setPrice($price);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setStock($stock);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setImage($image);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $item->setDescription($description);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (count($errors) == 0) {
            $name = $this->db->quote($item->getName());
            $price = $this->db->quote($item->getPrice());
            $stock = $this->db->quote($item->getStock());
            $image = $this->db->quote($item->getImage());
            $description = $this->db->quote($item->getDescription());
            $idCategory = $item->getCategory()->getId();
            $query = '	INSERT INTO item (id_category, name, price, stock, image, description)
								VALUES(' . $idCategory . ',' . $name . ',' . $price . ',' . $stock . ',' . $image . ',' . $description . ')';
            $res = $this->db->exec($query);
            if ($res) {
                $id = $this->db->lastInsertId();
                if ($id) {
                    return $this->readByID($id);
                } else {
                    throw new Exception('Internal server Error');
                }
            }
        }
    }
开发者ID:dispxxx,项目名称:leshop,代码行数:54,代码来源:ItemManager.class.php

示例2: testSetGetAllergyCategory

 public function testSetGetAllergyCategory()
 {
     // Arrange
     $item = new Item();
     $item->setCategory(1);
     $expectedResult = 1;
     // Act
     $result = $item->getCategory();
     // Assert
     $this->assertEquals($result, $expectedResult);
 }
开发者ID:Owen66,项目名称:KBK-WebSite,代码行数:11,代码来源:ItemTest.php

示例3: autoMail

 function autoMail()
 {
     global $database;
     //$itemsArr = array();
     $today = date("Y-m-d");
     $this->query = "select * from  items where BidEndOn ='{$today}' AND highest_bid!=0";
     $result = mysql_query($this->query);
     while ($row = mysql_fetch_array($result)) {
         $item = new Item();
         $item->setItemId($row["ItemID"]);
         $item->setTitle($row["Title"]);
         $item->setMinPrice($row["min_price"]);
         $item->setCategory($row["Category"]);
         $item->setOwnerId($row["OwnerID"]);
         $ad = date("Y-m-d H:i:s", strtotime($row['addedOn']));
         $item->setHighestBid($row["highest_bid"]);
         $item->setAddedOn($ad);
         $item->setBiddingEndOn($row["BidEndOn"]);
         $item->setDesc($row["Description"]);
         $item->setStatus($row["Status"]);
         $this->query = "SELECT PicDate,PicPath FROM itempics WHERE OwnId = " . $item->ownerId . " AND PicDate = '" . $ad . "'";
         $res = mysql_query($this->query);
         $r = mysql_fetch_array($res);
         $item->setPicPath($r['PicPath']);
         $this->query = "select email from user where UserID={$item->ownerId}";
         $res = mysql_query($this->query);
         $r = mysql_fetch_row($res);
         $OwnerEmail = $r[0];
         $this->query = "select bids.BidderID from items INNER JOIN bids ON items.highest_bid=bids.amount where items.ItemID ={$item->itemId}";
         $res = mysql_query($this->query);
         $r = mysql_fetch_row($res);
         $bidderId = $r[0];
         $this->query = "select email from user where UserID={$bidderId}";
         $res = mysql_query($this->query);
         $r = mysql_fetch_row($res);
         $WinnerEmail = $r[0];
         echo "\nOwner email:" . $OwnerEmail . "\n";
         echo "\nWinner email:" . $WinnerEmail . "\n";
         $this->query = "update account set balance=balance+{$item->highestBid} where UserID={$item->ownerId}";
         mysql_query($this->query);
         $this->query = "delete from bids where ItemID={$item->itemId}";
         mysql_query($this->query);
         $this->query = "update items set OwnerId ={$bidderId}, status='sold' where ItemID={$item->itemId}";
         mysql_query($this->query);
         $this->query = "insert into WonItems (winnerId,ownerId) values ({$bidderId}, {$item->ownerId} )";
         mailForOwner($OwnerEmail, $item);
         mailForWinner($WinnerEmail, $item);
     }
 }
开发者ID:ArslanAle,项目名称:eVeiling,代码行数:49,代码来源:AutoDao.php

示例4: getItem

 function getItem($id)
 {
     global $database;
     $item = new Item();
     $this->query = "select * from items where ItemID='{$id}'";
     $result = mysql_query($this->query);
     if (mysql_num_rows($result) > 0) {
         $row = mysql_fetch_row($result);
         $item->setItemId($row[0]);
         $item->setTitle($row[1]);
         $item->setMinPrice($row[2]);
         $item->setHighestBid($row[3]);
         $item->setCategory($row[4]);
         $item->setOwnerId($row[5]);
         $item->setAddedOn($row[6]);
         $item->setBiddingEndOn($row[7]);
         $item->setDesc($row[8]);
         $item->setStatus($row[9]);
     }
     return $item;
 }
开发者ID:ArslanAle,项目名称:eVeiling,代码行数:21,代码来源:ItemDao.php

示例5: createAction

 function createAction(Request $request, Application $app)
 {
     if (null === ($user = $app['session']->get('user'))) {
         return $app->redirect('/login');
     }
     $newItem = new Item();
     $newItem->setName($request->get('name'));
     $newItem->setDescription($request->get('description'));
     $newItem->setPrice($request->get('price'));
     $newItem->setCalories($request->get('calories'));
     $newItem->setAllergyInformation($request->get('allergyInformation'));
     $em = $app['orm.em'];
     $categoryRepository = $em->getRepository('Category');
     $Category = $categoryRepository->find($request->get('category'));
     $newItem->setCategory($Category);
     $file = $request->files->get('photo');
     $newItem->setPhoto($file->getClientOriginalName());
     $file = $request->files->get('photo');
     $file->move(__DIR__ . '/../public/img', $file->getClientOriginalName());
     $em->persist($newItem);
     $em->flush();
     return $app->redirect('/itemAdmin');
 }
开发者ID:Owen66,项目名称:KBK-WebSite,代码行数:23,代码来源:ItemController.php

示例6: while

								FROM post 
								LEFT JOIN category ON category_id = post_category_id 
								WHERE post_valid=1 
								LIMIT 10');
    while ($row = mysql_fetch_object($request)) {
        // Creating a new feed item
        $rssItem = new Item();
        $rssItem->setTitle($row->post_title);
        $rssItem->setDescription($row->post_description);
        $rssItem->setLink('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id);
        $rssItem->setGuid('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id, true);
        $rssItem->setComments('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id . '#comments');
        $rssItem->setAuthor($row->post_author_email, $row->post_author_name);
        $rssItem->setPubDate($row->post_date);
        $rssItem->setSource($row->post_source_uri, $row->post_source_name);
        $rssItem->setEnclosure('http://www.mywebsite.com/blog/images/nopicture.jpg', 2800, 'image/jpg');
        $rssItem->setCategory('http://www.mywebsite.com/blog/category.php.idCat=' . $row->category_id, $row->category_name);
        // Add the item to the feed
        $rssFeed->appendItem($rssItem);
    }
    // Save the feed
    $rssFeed->save();
    // SQL connection closing
    mysql_close();
    // Send headers to the browser
    header('Content-Type: text/xml; charset=utf-8');
    // Display the feed
    $rssFeed->display();
} catch (RSSFeedException $e) {
    echo $e->getErrorMessage();
}
开发者ID:kxopa,项目名称:WebSite-PHP,代码行数:31,代码来源:example2.php

示例7: Item

<?php

session_start();
require_once 'Logic/ItemLogic.php';
$title = $_POST['title'];
$minPrice = $_POST['minPrice'];
$category = $_POST['category'];
$Enddate = $_POST['inputDate'];
$desc = $_POST['desc'];
$item = new Item();
$item->setTitle($title);
$item->setMinPrice($minPrice);
$item->setCategory($category);
$item->setBiddingEndOn($Enddate);
$item->setDesc($desc);
$item->setOwnerId($_SESSION['user']);
//($_SESSION['user']);
$item->setStatus("available");
$itemLogic = new ItemLogic();
$itemLogic->insertItem($item);
?>

<script type="text/javascript">
	

</script>
<div class="c">
<form id="abc" method="post">
<div id="file-uploader-demo1">		
		<noscript>			
			<p>Please enable JavaScript to use file uploader.</p>
开发者ID:ArslanAle,项目名称:eVeiling,代码行数:31,代码来源:itemPicUpload.php

示例8: getPostedItems

 function getPostedItems($id)
 {
     global $database;
     $itemsArr = array();
     $this->query = "select * from items where ownerid={$id}";
     $result = mysql_query($this->query);
     if ($result) {
         while ($row = mysql_fetch_array($result)) {
             $item = new Item();
             $item->setItemId($row["ItemID"]);
             $item->setTitle($row["Title"]);
             $item->setMinPrice($row["min_price"]);
             $item->setCategory($row["Category"]);
             $item->setOwnerId($row["OwnerID"]);
             $ad = date("Y-m-d H:i:s", strtotime($row['addedOn']));
             $item->setHighestBid($row["highest_bid"]);
             $item->setAddedOn($ad);
             $item->setBiddingEndOn($row["BidEndOn"]);
             $item->setDesc($row["Description"]);
             $item->setStatus($row["Status"]);
             $this->query = "SELECT PicDate,PicPath FROM itempics WHERE OwnId = " . $item->ownerId . " AND PicDate = '" . $ad . "'";
             $res = mysql_query($this->query);
             $r = mysql_fetch_array($res);
             $item->setPicPath($r['PicPath']);
             array_push($itemsArr, $item);
         }
         return $itemsArr;
     }
 }
开发者ID:ArslanAle,项目名称:eVeiling,代码行数:29,代码来源:ItemDao.php


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