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


PHP DatabaseConnection::getDatabaseConnection方法代碼示例

本文整理匯總了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;
}
開發者ID:ArmandoPerez23,項目名稱:nearby,代碼行數:12,代碼來源:post.php

示例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>';
開發者ID:ArmandoPerez23,項目名稱:nearby,代碼行數:8,代碼來源:test.php

示例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 
}
開發者ID:ArmandoPerez23,項目名稱:nearby,代碼行數:26,代碼來源:register.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 
}
開發者ID:ArmandoPerez23,項目名稱:nearby,代碼行數:25,代碼來源:login.php


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