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


PHP Db::connect方法代碼示例

本文整理匯總了PHP中Db::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::connect方法的具體用法?PHP Db::connect怎麽用?PHP Db::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Db的用法示例。


在下文中一共展示了Db::connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Db

 function __construct()
 {
     include 'files/config.php';
     $msql = new Db();
     $msql->connect();
     $this->is_login();
 }
開發者ID:nerdgeeksu,項目名稱:FssWebSite,代碼行數:7,代碼來源:ajaxLoginModule.class.php

示例2: dologinAction

 public function dologinAction()
 {
     Db::connect();
     $bean = R::dispense('user');
     // the redbean model
     $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash'];
     \RedBeanFVM\RedBeanFVM::registerAutoloader();
     // for future use
     $fvm = \RedBeanFVM\RedBeanFVM::getInstance();
     $fvm->generate_model($bean, $required);
     //the magic
     R::store($bean);
     $val = new validation();
     $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false);
     $val->run();
     if (count($val->errors)) {
         Debug::r($val->errors);
         foreach ($val->errors as $error) {
             Notification::setMessage($error, Notification::TYPE_ERROR);
         }
         $this->redirect(Request::createUrl('login', 'login'));
     } else {
         Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS);
         Debug::r($val->sanitized);
         session::set('user', ['sanil']);
         $this->redirect(Request::createUrl('index', 'index'));
     }
 }
開發者ID:santonil2004,項目名稱:ovc,代碼行數:28,代碼來源:loginController.php

示例3: conectar

function conectar()
{
    $con = new Db("localhost", "root", "benjamin13");
    $con->connect();
    $con->select_db("conquistadores");
    return $con;
}
開發者ID:niko-afv,項目名稱:KS-Project,代碼行數:7,代碼來源:funciones.php

示例4: save

 public function save()
 {
     $query = "INSERT INTO miembros values (null,'" . $this->getNombre() . "',null,'" . $this->getEmail() . "')";
     $conn = new Db("localhost", "root", "benjamin13");
     $conn->connect();
     $conn->insert($query, "conquistadores");
 }
開發者ID:niko-afv,項目名稱:KS-Project,代碼行數:7,代碼來源:Miembro.php

示例5: login

 public function login()
 {
     $conn = Db::connect();
     $sql = 'SELECT user_id FROM users ' . ' WHERE email = ? AND password = ?';
     $email = $conn->real_escape_string($_POST['email']);
     $password = md5($_POST['password']);
     $statement = $conn->prepare($sql);
     $statement->bind_param('ss', $email, $password);
     $statement->execute();
     $statement->bind_result($userId);
     $statement->fetch();
     if ($userId == NULL) {
         return false;
     } else {
         session_start();
         $_SESSION['user_id'] = $userId;
         if (isset($_SESSION['cart']) && $_SESSION['cart'] != []) {
             require_once '../app/models/Cart.php';
             $cart = new Cart();
             foreach ($_SESSION['cart'] as $product_id => $value) {
                 $cart->addProductToCart($product_id, $_SESSION['cart'][$product_id]['cart_quantity']);
             }
         }
         return true;
     }
 }
開發者ID:matthewleighton,項目名稱:online_shop,代碼行數:26,代碼來源:sessions_helper.php

示例6: getStandartTheme

 public static function getStandartTheme()
 {
     $db = Db::connect();
     $query = "SELECT themes.file FROM themes WHERE themes.id = 1";
     $result = $db->query($query)->fetch(PDO::FETCH_ASSOC);
     return $result['file'];
 }
開發者ID:yasch-kub,項目名稱:auroracing.com,代碼行數:7,代碼來源:PageModel.php

示例7: deleteArticleById

 public function deleteArticleById($id)
 {
     $pdo = Db::connect();
     $sql = "DELETE FROM `article` WHERE `article_id` = {$id}";
     $query_result = $pdo->query($sql);
     return $query_result;
 }
開發者ID:nllx,項目名稱:mvc,代碼行數:7,代碼來源:ArticleModel.php

示例8: __construct

 /**
  * Prywatny konstruktor klasy inicjujący połączenie z bazą danych
  * @global type $CONFIG mixed tablica przechowująca configuracje systemu
  */
 private function __construct()
 {
     global $CONFIG;
     self::$connect = new PDO('mysql:host=' . $CONFIG["host"] . ";dbname=" . $CONFIG["database"], $CONFIG["user"], $CONFIG["pass"]);
     self::$connect->query("SET NAMES utf8");
     self::$connect->query("SET CHARSET utf8");
     self::$connect->num_queries = 0;
 }
開發者ID:whitcik,項目名稱:CeneoComments,代碼行數:12,代碼來源:Db.php

示例9: db

 /**
  * Return an instance of Db Class
  * If not connection to the database is made then firstly will try to connect to the database
  * If connection to the database fails then `false` value will be returned
  * 
  * @return  Mixed;
  */
 public function db()
 {
     if (!self::$db) {
         self::$db = new Db($this->config('db'));
         self::$db->connect();
     }
     return self::$db;
 }
開發者ID:spirlici,項目名稱:spcms,代碼行數:15,代碼來源:mvc.class.php

示例10: incrementProductQuantity

 public static function incrementProductQuantity($productId, $quantity)
 {
     $sql = "UPDATE shopping_cart SET cart_quantity = cart_quantity + ? " . "WHERE fk_shopping_cart_user = ? AND fk_shopping_cart_product_version = ?";
     $conn = Db::connect();
     $statement = $conn->prepare($sql);
     $statement->bind_param('iii', $quantity, $_SESSION['user_id'], $productId);
     $statement->execute();
 }
開發者ID:matthewleighton,項目名稱:online_shop,代碼行數:8,代碼來源:carts_helper.php

示例11: setup

 public function setup()
 {
     global $baseParams;
     $db = new Db($baseParams['__YKVAL_DB_DSN__'], 'root', 'lab', $baseParams['__YKVAL_DB_OPTIONS__']);
     $db->connect();
     # $db->truncateTable('queue');
     $db->disconnect();
 }
開發者ID:netcetera,項目名稱:yubikey-val-server-php,代碼行數:8,代碼來源:syncLibTest.php

示例12: destroy

 public function destroy($wishListId)
 {
     $sql = 'DELETE FROM wish_list WHERE wish_list_id = ?';
     $conn = Db::connect();
     $stmt = $conn->prepare($sql);
     $stmt->bind_param('i', $wishListId);
     $stmt->execute();
     $stmt->close();
 }
開發者ID:matthewleighton,項目名稱:online_shop,代碼行數:9,代碼來源:Wish_list.php

示例13: table

 static function table($with_db_name = true)
 {
     $conn = Db::getConnection('streams');
     $prefix = empty($conn['prefix']) ? '' : $conn['prefix'];
     $table_name = $prefix . 'notification';
     if (!$with_db_name) {
         return $table_name;
     }
     $db = Db::connect('streams');
     return $db->dbName() . '.' . $table_name;
 }
開發者ID:EGreg,項目名稱:PHP-On-Pie,代碼行數:11,代碼來源:Notification.php

示例14: emptyCart

 public function emptyCart()
 {
     $sql = 'DELETE FROM shopping_cart WHERE fk_shopping_cart_user = ?';
     $database = Db::connect();
     $statement = $database->prepare($sql);
     $statement->bind_param('i', $_SESSION['user_id']);
     $statement->execute();
     if (isset($_SESSION['cart'])) {
         unset($_SESSION['cart']);
     }
 }
開發者ID:matthewleighton,項目名稱:online_shop,代碼行數:11,代碼來源:Cart.php

示例15: runConfirmationQuery

 private function runConfirmationQuery($sql, $id)
 {
     $conn = Db::connect();
     $stmt = $conn->prepare($sql);
     $stmt->bind_param('ii', $id, $_SESSION['user_id']);
     $stmt->execute();
     $stmt->bind_result($id);
     $stmt->fetch();
     $conn->close();
     $_SESSION['test'] = $id;
     return $id;
 }
開發者ID:matthewleighton,項目名稱:online_shop,代碼行數:12,代碼來源:Checkout_helper.php


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