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


PHP Publisher::GetId方法代碼示例

本文整理匯總了PHP中Publisher::GetId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Publisher::GetId方法的具體用法?PHP Publisher::GetId怎麽用?PHP Publisher::GetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Publisher的用法示例。


在下文中一共展示了Publisher::GetId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Add

 public static function Add($conn, $params)
 {
     //peredelat Add nehvatilo vremeni ...
     $q = "SELECT id FROM books WHERE books.name = '{$params['book_name']}'";
     $res = $conn->query($q);
     $zzz = $res->fetch_row();
     if (count($zzz)) {
         echo "Book already exist in database";
         return;
     }
     if ($params['book_name'] == "") {
         echo "Empty book name";
         return;
     }
     if (Category::GetId($conn, $params['category']) < 0) {
         $q = "INSERT INTO Categories (name) VALUES ('{$params['category']}')";
         $conn->query($q);
     }
     if (Publisher::GetId($conn, $params['publisher_name']) < 0) {
         $q = "INSERT INTO Publishers (name) VALUES ('{$params['publisher_name']}')";
         $conn->query($q);
     }
     if (Author::GetId($conn, $params['author_name'], $params['author_surname'], $params['author_birthdate']) < 0) {
         $q = "INSERT INTO Authors (name, surname, birthdate) " . "VALUES ('{$params['author_name']}', '{$params['author_surname']}', '{$params['author_birthdate']}')";
         $conn->query($q);
     }
     $q = "INSERT INTO Books (name, pages, date, category_id, publisher_id) " . "VALUES ('{$params['book_name']}', '{$params['pages']}', '{$params['date']}', " . "(SELECT id FROM Categories WHERE Categories.name = '{$params['category']}'), " . "(SELECT id FROM Publishers WHERE Publishers.name = '{$params['publisher_name']}'))";
     //echo $q;
     $conn->query($q);
     $q = "INSERT INTO BooksAuthors (book_id, author_id) VALUES (" . "(SELECT id FROM Books WHERE Books.name = '{$params['book_name']}'), " . "(SELECT id FROM Authors WHERE Authors.name = '{$params['author_name']}' AND " . "Authors.surname = '{$params['author_surname']}' AND " . "Authors.birthdate = '{$params['author_birthdate']}'))";
     //echo $q;
     $conn->query($q);
     echo "Book was added in the database   ";
     //echo Category::GetId($conn, $params['category']);
     //echo Publisher::GetId($conn, $params['publisher_name']);
     //echo Author::GetId($conn, $params['author_name'], $params['author_surname'], $params['author_birthdate']);
 }
開發者ID:usfuprog,項目名稱:Library_ap,代碼行數:37,代碼來源:model_book.php


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