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