本文整理汇总了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);
}
示例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;
}
示例3: getId
public function getId($plain = false)
{
if ($plain) {
return parent::getId();
}
return 'gallery' . parent::getId();
}
示例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());
}
示例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']++;
}
}
示例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']++;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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');
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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.");
}
}