本文整理汇总了PHP中DatabaseConnection::getDatabaseConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::getDatabaseConnection方法的具体用法?PHP DatabaseConnection::getDatabaseConnection怎么用?PHP DatabaseConnection::getDatabaseConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::getDatabaseConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
function post()
{
try {
$post = new UserPost(DatabaseConnection::getDatabaseConnection());
$post->title($_POST["title"])->state($_POST["state"])->description($_POST["description"])->save();
return true;
} catch (Exception $e) {
$errorMessage = json_decode($e->getMessage(), true);
return $errorMessage["err_message"];
}
return false;
}
示例2:
<?php
require "DatabaseConnection.php";
$db = DatabaseConnection::getDatabaseConnection();
echo 'something';
echo '<pre>';
var_dump($db->query("SELECT * FROM test_post")->fetchAll(PDO::FETCH_ASSOC));
echo '</pre>';
示例3: UserSignUp
<?php
require_once "DatabaseConnection.php";
require_once "db-functionalities/UserSignUp.php";
try {
if (!empty($_POST)) {
$signup = new UserSignUp(DatabaseConnection::getDatabaseConnection());
$response = $signup->firstName($_POST["firstname"])->lastName($_POST["lastname"])->username($_POST["username"])->password($_POST["passwordSignUp01"], $_POST["passwordSignUp02"])->save();
if (json_decode($response, true)["message"] === "success") {
?>
<div class="alert alert-success custom-alert">
Registered successfully. <a href="index.php">Sign In</a>
</div>
<?php
}
}
} catch (Exception $e) {
$errorMessage = json_decode($e->getMessage(), true);
?>
<div class="alert alert-danger custom-alert">
<?php
echo $errorMessage["err_message"];
?>
</div>
<?php
}
示例4: session_start
<?php
session_start();
require_once "DatabaseConnection.php";
require_once "db-functionalities/UserSignIn.php";
try {
if (!empty($_POST)) {
$signin = new UserSignIn(DatabaseConnection::getDatabaseConnection());
$response = $signin->username($_POST["username"])->password($_POST["password"])->retrieve();
if (json_decode($response, true)["message"] === "success") {
$_SESSION["open"] = true;
$_SESSION["username"] = $_POST["username"];
header("Location:wall.php");
}
}
} catch (Exception $e) {
$errorMessage = json_decode($e->getMessage(), true);
?>
<div class="alert alert-danger custom-alert">
<?php
echo $errorMessage["err_message"];
?>
</div>
<?php
}