本文整理汇总了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();
}
示例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'));
}
}
示例3: conectar
function conectar()
{
$con = new Db("localhost", "root", "benjamin13");
$con->connect();
$con->select_db("conquistadores");
return $con;
}
示例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");
}
示例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;
}
}
示例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'];
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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']);
}
}
示例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;
}