本文整理汇总了PHP中Book::deleteBook方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::deleteBook方法的具体用法?PHP Book::deleteBook怎么用?PHP Book::deleteBook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::deleteBook方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleDELETE
function handleDELETE()
{
$conn = Connection::startConnection();
$id = file_get_contents("php://input");
$book = new Book();
$book->deleteBook($conn, $id);
Connection::stopConnecion($conn);
header('Content-type: application/json');
}
示例2: testDeleteBook
function testDeleteBook()
{
$title = "BRING ON THE PAIN";
$id = 1;
$test_book = new Book($title, $id);
$test_book->save();
$title2 = "Oh Yeah";
$id2 = 2;
$test_book2 = new Book($title2, $id2);
$test_book2->save();
$test_book->deleteBook();
$this->assertEquals([$test_book2], Book::getAll());
}
示例3: deleteBook
<?php
class Book
{
public function deleteBook()
{
$tid = $_GET['tid'];
$link = mysql_connect('localhost', 'root', '') or die('No se pudo conectar al servidor: ' . mysql_error());
mysql_select_db('books') or die('No se pudo seleccionar la base de datos');
mysql_query("SET NAMES 'utf8'");
$query = "DELETE FROM `books` WHERE `books`.`id` = {$tid}";
$result = mysql_query($query) or die('Consulta fallida: ' . mysql_error());
if ($result) {
echo "Eliminado.";
unlink("archivo" . $tid . ".html");
}
mysql_close($link);
}
}
$book = new Book();
$book->deleteBook();
echo "<br><br>";
echo "<a href='index.php'>Back</a>";