当前位置: 首页>>代码示例>>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;未经允许,请勿转载。