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


PHP Item::getId方法代码示例

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


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

示例1: gettersShouldReturnTheAttributeValue

 /**
  * @test
  */
 public function gettersShouldReturnTheAttributeValue()
 {
     $this->assertAttributeEquals($this->item->getId(), 'id', $this->item);
     $this->assertAttributeEquals($this->item->getDescription(), 'description', $this->item);
     $this->assertAttributeEquals($this->item->getAmount(), 'amount', $this->item);
     $this->assertAttributeEquals($this->item->getQuantity(), 'quantity', $this->item);
     $this->assertAttributeEquals($this->item->getShippingCost(), 'shippingCost', $this->item);
     $this->assertAttributeEquals($this->item->getWeight(), 'weight', $this->item);
 }
开发者ID:leonardorifeli,项目名称:pagseguro,代码行数:12,代码来源:ItemTest.php

示例2: verificar

 /**
  *
  * @param Usuario $usuario
  * @return int Key for Inventario
  */
 public function verificar(Usuario $usuario)
 {
     $inventarios = $usuario->getInventario()->toArray();
     $inventario = null;
     $key = null;
     foreach ($inventarios as $k => $i) {
         if ($i->getItem()->getId() == $this->item->getId()) {
             $inventario = $i;
             $key = $k;
         }
     }
     if (is_null($inventario)) {
         throw new \Exception('Não possui o item: ' . $this->item->getNome());
     }
     return $key;
 }
开发者ID:raphaeldealmeida,项目名称:Demagogos,代码行数:21,代码来源:RequisitoItem.php

示例3: getId

 public function getId($plain = false)
 {
     if ($plain) {
         return parent::getId();
     }
     return 'gallery' . parent::getId();
 }
开发者ID:appshed,项目名称:extension-api,代码行数:7,代码来源:GalleryImage.php

示例4: testGetId

 /**
  * Test right the execution of an item callback.
  *
  * @covers ::__construct
  * @covers ::getId
  * @return void
  */
 public function testGetId()
 {
     $str = 'HoLa MuNdo';
     $item = new Item(function ($string) {
         return strtolower($string);
     }, $str);
     $this->assertNotNull($item->getId());
 }
开发者ID:BD-ES,项目名称:Q,代码行数:15,代码来源:ItemTest.php

示例5: addItem

 /**
  * @param  Item $item
  * @return void
  **/
 public function addItem(Item $item)
 {
     $id = $item->getId();
     if (!array_key_exists($id, $this->items)) {
         $this->items[$id] = array('object' => $item, 'amount' => 0);
         $this->items[$id]['amount']++;
     }
 }
开发者ID:app2641,项目名称:DesignPatternOnPHP,代码行数:12,代码来源:Order.php

示例6: addItem

 public function addItem(Item $item)
 {
     $id = $item->getId();
     if (!array_key_exists($id, $this->items)) {
         $this->items[$id]['object'] = $item;
         $this->items[$id]['amount'] = 0;
     }
     $this->items[$id]['amount']++;
 }
开发者ID:JJmaz,项目名称:dp,代码行数:9,代码来源:Order.php

示例7: add

 public function add(Item $item)
 {
     //ak uz existuje, pripocita pocet
     $old_item = $this->mapper->find($item->getId());
     if ($old_item) {
         $count = $old_item->count + $count;
     }
     $this->mapper->save($item, $count);
     return $item;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:10,代码来源:Repository.php

示例8: __construct

 /**
  * @return void
  **/
 public function __construct()
 {
     $fp = fopen(ROOT . '/data/AbstractFactory/item.csv', 'r');
     while ($data = fgetcsv($fp, 1000, ',')) {
         $item = new Item();
         $item->setId($data[0]);
         $item->setName($data[1]);
         $this->items[$item->getId()] = $item;
     }
     fclose($fp);
 }
开发者ID:app2641,项目名称:DesignPatternOnPHP,代码行数:14,代码来源:DbItemDao.php

示例9: Item

 function test_find()
 {
     //Arrange
     $name = "Hello Kitty";
     $name2 = "Pokemon";
     $test_Item = new Item($name);
     $test_Item->save();
     $test_Item2 = new Item($name2);
     $test_Item2->save();
     //Act
     $result = Item::find($test_Item2->getId());
     //Assert
     $this->assertEquals($test_Item2, $result);
 }
开发者ID:Camolot,项目名称:inventory-PHP-databases,代码行数:14,代码来源:itemTest.php

示例10: updateItem

 /**
  *
  * @param Item $item
  * @return type
  * @throws DaoException 
  */
 public function updateItem(Item $item)
 {
     try {
         $query = Doctrine_Query::create()->update('Item i');
         $query->set('i.name', '?', $item->getName());
         $query->set('i.sales_unit_price', '?', $item->getSalesUnitPrice());
         $query->set('i.purchase_unit_price', '?', $item->getPurchaseUnitPrice());
         $query->set('i.description', '?', $item->getDescription());
         $query->set('i.stock_available', '?', $item->getStockAvailable());
         $query->where('i.id = ?', $item->getId());
         return $query->execute();
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:GarraouiMarwen,项目名称:open-stock-management,代码行数:21,代码来源:ItemDao.php

示例11: findPhotosByItem

 /**
  * @param Item $item
  * @return mixed
  * @throws Exception
  */
 public function findPhotosByItem(Item $item)
 {
     $id_item = $item->getId();
     $query = "SELECT * FROM photo_item WHERE id_item = " . $id_item;
     $data = $this->db->query($query);
     if ($data) {
         $photos = $data->fetchAll(PDO::FETCH_CLASS, "Item", array($this->db));
         if ($photos) {
             return $photos;
         } else {
             throw new Exception('Fetch error');
         }
     } else {
         throw new Exception('Query error');
     }
 }
开发者ID:CreepingPanda,项目名称:FennecPlusUltra,代码行数:21,代码来源:ItemManager.class.php

示例12: __construct

 private function __construct()
 {
     $fp = fopen('item_data.txt', 'r');
     /**
      *
      */
     $dummy = fgets($fp, 4096);
     $this->item = array();
     while ($buffer = fgets($fp, 4096)) {
         $item_id = trim(substr($buffer, 0, 10));
         $item_name = trim(substr($buffer, 10, 20));
         $item_price = trim(substr($buffer, 30));
         //echo 'id:'.$item_id. "\n";
         $item = new Item($item_id, $item_name, $item_price);
         $this->items[$item->getId()] = $item;
     }
     fclose($fp);
 }
开发者ID:JlR0-tt,项目名称:memo,代码行数:18,代码来源:ItemDao.class.php

示例13: save

 public function save(Item $item, $count)
 {
     $count = (int) $count;
     if ($item->getId() === NULL) {
         // insert
         $data = $this->itemToData($item);
         // vytáhne data z entity a vrátí jako pole
         $id = $this->conn->insert('shopping_cart', $data)->execute();
         $this->setIdentity($item, $id);
     } else {
         // update
         $data = $this->itemToData($item);
         // vytáhne data z entity a vrátí jako pole
         // tady se velice hodí logika, která porovná v jakém stavu byla entita při načtení
         // a v jakém je teď, aby se nemuselo posílat všechno, ale to jsou hodně pokročílé funkce
         // a optimalizace se má dělat až když je potřeba, že :)
         $this->conn->update('shopping_cart', $data)->where('id = %i', $item->getId())->execute();
     }
 }
开发者ID:oaki,项目名称:demoshop,代码行数:19,代码来源:DibiMapper.php

示例14: __construct

 private function __construct()
 {
     $fp = fopen(dirname(__DIR__) . '/item_data.txt', 'r');
     /**
      * ヘッダ行を抜く
      */
     $dummy = fgets($fp, 4096);
     $this->items = array();
     while (($buffer = fgets($fp, 4096)) !== false) {
         $data = explode("\t", trim($buffer));
         if (count($data) !== 3) {
             continue;
         }
         list($item_id, $item_name, $item_price) = $data;
         $item = new Item($item_id, $item_name, $item_price);
         $this->items[$item->getId()] = $item;
     }
     fclose($fp);
 }
开发者ID:JJmaz,项目名称:dp,代码行数:19,代码来源:ItemDao.php

示例15: addToCart

 public function addToCart(User $user, Item $item, $quantity)
 {
     $idItem = intval($item->getId());
     if (ctype_digit($quantity)) {
         if ($quantity > 0) {
             if ($quantity <= $item->getStock()) {
                 $quantity = intval($quantity);
             } else {
                 $quantity = intval($item->getStock());
             }
             if ($quantity) {
                 if (isset($_SESSION['id'])) {
                     $idCart = intval($user->getCart()->getId());
                     $query = "INSERT INTO order (id_cart, id_item, quantity) VALUES (" . $idCart . ", " . $idItem . ", " . $quantity . ")";
                     $result = $this->database->exec($query);
                     if ($result) {
                         $id = $this->database->lastInsertId();
                         if ($id) {
                             return $user->getCart();
                         } else {
                             throw new Exception("Catastrophe serveur.");
                         }
                     } else {
                         throw new Exception("Catastrophe base de données.");
                     }
                 } else {
                     throw new Exception("Erreur vraiment bizarre, là, je peux pas aider.");
                 }
             } else {
                 throw new Exception("Pas de quantité, sérieusement ? ON ENVOIE AU HASARD ?");
             }
         } else {
             throw new Exception("La quantité doit être supérieure à 0, vilain violeur de poules.");
         }
     } else {
         throw new Exception("La quantité doit être un nombre, vilain lutin violeur de lapins.");
     }
 }
开发者ID:CreepingPanda,项目名称:FennecPlusUltra,代码行数:38,代码来源:CartManager.class.php


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