當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inventory::getAll方法代碼示例

本文整理匯總了PHP中Inventory::getAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inventory::getAll方法的具體用法?PHP Inventory::getAll怎麽用?PHP Inventory::getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inventory的用法示例。


在下文中一共展示了Inventory::getAll方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: find

 static function find($search_id)
 {
     $found_item = null;
     $items = Inventory::getAll();
     foreach ($items as $item) {
         $item_id = $item->getId();
         if ($item_id == $search_id) {
             $found_item = $item;
         }
     }
     return $found_item;
 }
開發者ID:kylepratuch,項目名稱:Inventory,代碼行數:12,代碼來源:Inventory.php

示例2: test_deleteAll

 function test_deleteAll()
 {
     $item = "POGs";
     $item2 = "Pokemon Cards";
     $test_item = new Inventory($item);
     $test_item->save();
     $test_item2 = new Inventory($item2);
     $test_item2->save();
     Inventory::deleteAll();
     $result = Inventory::getAll();
     $this->assertEquals([], $result);
 }
開發者ID:CaseyH33,項目名稱:Inventory-MySQL,代碼行數:12,代碼來源:InventoryTest.php

示例3: find

 static function find($search_item)
 {
     $found_item = NULL;
     $inventory = Inventory::getAll();
     foreach ($inventory as $item) {
         $item_name = $item->getItem();
         if ($item_name == $search_item) {
             $found_item = $item;
         }
     }
     return $found_item;
 }
開發者ID:CaseyH33,項目名稱:Inventory-MySQL,代碼行數:12,代碼來源:Inventory.php

示例4: find

 static function find($search_id)
 {
     $found_inventory = null;
     $inventory_array = Inventory::getAll();
     foreach ($inventory_array as $inventory_item) {
         $inventory_id = $inventory_item->getId();
         if ($inventory_id == $search_id) {
             $found_inventory = $inventory_item;
         }
     }
     return $found_inventory;
 }
開發者ID:CharlesAMoss,項目名稱:epic_Inventory,代碼行數:12,代碼來源:Inventory.php

示例5: test_deleteAll

 function test_deleteAll()
 {
     //Arrange
     $item = "Antique Toothpick Holders";
     $item2 = "Ornamental Mouse Traps";
     $test_Inventory = new Inventory($item);
     $test_Inventory->save();
     $test_Inventory2 = new Inventory($item2);
     $test_Inventory2->save();
     //Act
     Inventory::deleteAll();
     //Assert
     $result = Inventory::getAll();
     $this->assertEquals([], $result);
 }
開發者ID:alexdbrown,項目名稱:sql-inventory,代碼行數:15,代碼來源:InventoryTest.php

示例6: test_deleteAll

 function test_deleteAll()
 {
     //Arrange
     $description = "Blue candy";
     $description2 = "Light blue candy";
     $test_Inventory = new Inventory($description);
     $test_Inventory->save();
     $test_Inventory2 = new Inventory($description2);
     $test_Inventory2->save();
     //Act
     Inventory::deleteAll();
     //Assert
     $result = Inventory::getAll();
     $this->assertEquals([], $result);
 }
開發者ID:kylepratuch,項目名稱:Inventory,代碼行數:15,代碼來源:InventoryTest.php

示例7: PDO

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Inventory.php";
$app = new Silex\Application();
$server = 'mysql:host=localhost;dbname=inventory';
$username = 'root';
$password = 'root';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('inventory' => Inventory::getAll()));
});
$app->post("/create", function () use($app) {
    $inventory = new Inventory($_POST['item']);
    $inventory->save();
    return $app['twig']->render('index.html.twig', array('inventory' => Inventory::getAll()));
});
$app->post("/delete", function () use($app) {
    Inventory::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->get("/search", function () use($app) {
    $search = Inventory::find($_GET['search']);
    return $app['twig']->render('search.html.twig', array('search' => $search, 'search_term' => $_GET['search']));
});
return $app;
開發者ID:CaseyH33,項目名稱:Inventory-MySQL,代碼行數:27,代碼來源:app.php

示例8: PDO

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Inventory.php";
$app = new Silex\Application();
$server = 'mysql:host=localhost;dbname=inventory';
$username = 'root';
$password = 'root';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('candies' => Inventory::getAll()));
});
$app->get("/candies", function () use($app) {
    return $app['twig']->render('candies.html.twig', array('candies' => Inventory::getAll()));
});
$app->post("/candies", function () use($app) {
    $candy = new Inventory($_POST['name']);
    $candy->save();
    return $app['twig']->render('candies.html.twig', array('candies' => Inventory::getAll()));
});
$app->post("/delete_candy", function () use($app) {
    Inventory::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->get("/found_candy", function () use($app) {
    return $app['twig']->render('found_candy.html.twig', array('candies' => Inventory::find($_GET['search'])));
});
return $app;
開發者ID:kylepratuch,項目名稱:Inventory,代碼行數:29,代碼來源:app.php


注:本文中的Inventory::getAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。