本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
示例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;