本文整理匯總了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
}