本文整理汇总了PHP中Animal::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Animal::deleteAll方法的具体用法?PHP Animal::deleteAll怎么用?PHP Animal::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animal
的用法示例。
在下文中一共展示了Animal::deleteAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_deleteAll
function test_deleteAll()
{
//Arrange
$type = "dog";
$id = null;
$test_animal_type = new AnimalType($type, $id);
$test_animal_type->save();
$name = 'Sparky';
$gender = 'Male';
$breed = 'Pug';
$admit_date = '2015-08-18';
$type_id = $test_animal_type->getId();
$test_animal = new Animal($name, $gender, $breed, $admit_date, $type_id);
$test_animal->save();
$name2 = 'Senna';
$gender2 = 'Male';
$breed2 = 'Domestic Shorthair';
$admit_date2 = '2015-07-28';
$type_id2 = $test_animal_type->getId();
$test_animal2 = new Animal($name, $gender, $breed, $admit_date, $type_id);
$test_animal2->save();
//Act
Animal::deleteAll();
//Assert
$result = Animal::getAll();
$this->assertEquals([], $result);
}
示例2: function
$app->get("/types", function () use($app) {
return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->get("/types/{id}", function ($id) use($app) {
$type = Type::find($id);
return $app['twig']->render('types.html.twig', array('types' => $type, 'animals' => $type->getAnimals()));
});
$app->post("/animals", function () use($app) {
$name = $_POST['name'];
$gender = $_POST['gender'];
$breed = $_POST['breed'];
$age = $_POST['age'];
$type_id = $_POST['type_id'];
$animal = new Animal($name, $gender, $breed, $age, $type_id, $id = null);
$animal->save();
$type = Type::find($type_id);
return $app['twig']->render('types.html.twig', array('types' => $type, 'animals' => Animal::getAll()));
});
$app->post("/types", function () use($app) {
$type = new Type($_POST['name']);
$type->save();
return $app['twig']->render('index.html.twig', array('types' => Type::getAll()));
});
$app->post("/delete_types", function () use($app) {
Animal::deleteAll();
Type::deleteAll();
return $app['twig']->render('index.html.twig', array('types' => Type::getAll()));
});
return $app;
?>