本文整理汇总了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.';
}
}
}
示例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();
}
}
示例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.';
}
}
示例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();
}
}