本文整理匯總了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>";