當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Author::selectAllAuthors方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:Gecata-,項目名稱:PHP,代碼行數:28,代碼來源:BookModel.php

示例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');
}
開發者ID:Gecata-,項目名稱:PHP,代碼行數:20,代碼來源:newBookControler.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();
}
開發者ID:Gecata-,項目名稱:PHP,代碼行數:29,代碼來源:newAuthor.php


注:本文中的Author::selectAllAuthors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。