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