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


PHP Index::DB方法代碼示例

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


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

示例1: deleteContact

 private function deleteContact($recordId)
 {
     if (is_int((int) $recordId)) {
         $db = Index::DB();
         $query = $db->prepare("DELETE FROM address_book WHERE id = ?");
         $result = $query->execute([$recordId]);
         if ($result) {
             header("Location: " . Index::config()['url'] . 'address-book');
         } else {
             self::$data['error'] = 'Błąd przy usuwaniu kontaktu.';
         }
     }
 }
開發者ID:masteruser20,項目名稱:Blog,代碼行數:13,代碼來源:AddressBook.php

示例2: addPost

 private function addPost($data)
 {
     try {
         $db = Index::DB();
         $query = $db->prepare("INSERT INTO posts (title, text, author, date, categories_id) VALUES (?, ?, ?, ?, ?)");
         $query->execute([htmlentities($_POST['title']), htmlentities($_POST['text']), $_SESSION['id'], (new DateTime())->format('Y-m-d H:i:s'), (int) $_POST['category']]);
         unset($_POST);
         return true;
     } catch (PDOException $p) {
         echo $p->getMessage();
         self::$data['errorForm'] = 'Błąd przy wysyłaniu formularza.';
         return false;
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
開發者ID:masteruser20,項目名稱:Blog,代碼行數:16,代碼來源:AddPost.php

示例3: addComm

 private function addComm($data)
 {
     try {
         if ((int) $data['answer'] == (int) $data['good-answer']) {
             try {
                 $db = Index::DB();
                 $query = $db->prepare("INSERT INTO comms (email, text, post_id, date) VALUES (?, ?, ?, ?)");
                 $query->execute([htmlentities($_POST['email']), htmlentities($_POST['text']), $_POST['post_id'], (new DateTime())->format('Y-m-d H:i:s')]);
                 header("Refresh:0");
                 unset($_POST);
             } catch (PDOException $s) {
                 var_dump($s->getMessage());
             }
         } else {
             self::$data['errorForm'] = 'Zła captcha.';
         }
     } catch (Exception $e) {
         self::$data['errorForm'] = 'Błąd przy wysyłaniu formularza.';
     }
 }
開發者ID:masteruser20,項目名稱:Blog,代碼行數:20,代碼來源:ShowPost.php

示例4: __construct

 function __construct($_data = null)
 {
     $data = [];
     $email = $_data["email"];
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $data['error']['email'] = "Zły format maila";
         return false;
     }
     if (isset($data['error'])) {
         self::setFormResultsModel($data['error']);
     } else {
         $data['results'] = ['Nick' => $_data["nick"], 'Email' => $email, 'GG' => $_data['gg'], 'WWW' => $_data['www'], 'Komentarz' => $_data['kom']];
         mail('tk940525@gmail.com', 'Blog', $_data['kom']);
         self::setFormResultsModel($data);
     }
     try {
         $db = Index::DB();
         $query = $db->prepare("SELECT * FROM posts WHERE id = ? LIMIT 1");
         $query->execute([1]);
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
開發者ID:masteruser20,項目名稱:Blog,代碼行數:23,代碼來源:FormResults.php


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