本文整理汇总了PHP中Author::selectAllAuthors方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::selectAllAuthors方法的具体用法?PHP Author::selectAllAuthors怎么用?PHP Author::selectAllAuthors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author::selectAllAuthors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertBook
public function insertBook($bookName, $bookAuthor)
{
$stmt = mysqli_prepare($this->connection, 'INSERT INTO books(book_title) VALUES (?)');
mysqli_stmt_bind_param($stmt, 's', $bookName);
mysqli_stmt_execute($stmt);
$authorId = [];
$author = new Author();
$allAuthors = $author->selectAllAuthors();
foreach ($bookAuthor as $au) {
foreach ($allAuthors as $key => $value) {
if ($au == $value) {
$authorId[] = $key;
}
}
}
$books = $this->getBook();
$keyID = 0;
foreach ($books as $key => $title) {
if ($title == $bookName) {
$keyID = $key;
}
}
$stmt2 = mysqli_prepare($this->connection, 'INSERT INTO books_authors(book_id,author_id) VALUES (?,?)');
for ($i = 0; $i < count($authorId); $i++) {
mysqli_stmt_bind_param($stmt2, 'ii', $keyID, $authorId[$i]);
mysqli_stmt_execute($stmt2);
}
}
示例2: Author
<?php
/**
* Created by PhpStorm.
* User: gdimitrov
* Date: 30.9.2015 г.
* Time: 12:54 ч.
*/
include '../DB/mySQL.php';
include '../Model/Author.php';
include '../Model/BookModel.php';
$aut = new Author();
$authors = $aut->selectAllAuthors();
if ($_POST) {
$bookAuthors = $_POST['authors'];
$bookName = $_POST['bookName'];
$book = new BookModel();
$book->insertBook($bookName, $bookAuthors);
header('Location: ../View/allBooks.php');
}
示例3: Author
<?php
/**
* Created by PhpStorm.
* User: gdimitrov
* Date: 30.9.2015 г.
* Time: 10:55 ч.
*/
include '../DB/mySQL.php';
include '../Model/Author.php';
try {
$aut = new Author();
if ($_POST) {
$author = trim($_POST['authorName']);
if (mb_strlen($author) < 3) {
$minLenght = 'Името на автора не трябва да е по-малко от 3 символа.';
} else {
if ($aut->checkRepeatName($author)) {
$minLenght = 'Автора: ' . $author . ' , който се опитвате да добавите, вече съществува в списъка!';
} else {
$aut->insertAuthor($author);
header('Location: ../View/allBooks.php');
}
}
}
$booksAndAuthors = $aut->selectAllAuthors();
} catch (Exception $exc) {
echo $exc->getMessage();
}