PHP User::db Examples

PHP User::db - 7 examples found. These are the top rated real world PHP examples of User::db extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 /**
  * metoda pro zjisteni, zda prihlasovany uzivatel ma pravo na vstup do admina
  * @param    array   $credentials vyplnene udaje v prihlasovacim formulari
  */
 public function authenticate(array $credentials)
 {
     self::$db = \DatabaseModel::getInstance();
     $username = $credentials['username'];
     $password = $credentials['password'];
     $row = self::$db->getUser($username);
     if ($row) {
         $password_is_correct = password_verify($password, $row['password']);
         if ($password_is_correct !== true) {
             throw new Exception('Špatně zadané heslo');
         } else {
             $_SESSION['username'] = $row['username'];
             $_SESSION['rights'] = $row['rights_level'];
         }
     } else {
         throw new Exception('Špatně zadané jméno');
     }
 }
Example #2
0
 public function initialize()
 {
     self::$db = new MDB('ar');
 }
<?php

namespace Model;

User::$db = $db;
class User extends \Model
{
    protected static $table = 'user';
    public static $db = NULL;
    public function __construct($id = '')
    {
        parent::$db = self::$db;
        parent::__construct($id);
    }
}
Example #4
0
 static function init($db)
 {
     User::$db = $db;
 }
Example #5
0
 public static function setConnection(mysqli $newConn)
 {
     self::$db = $newConn;
 }
Example #6
0
 public static function getDB()
 {
     if (User::$db === NULL) {
         User::$db = new PDO('sqlite:' . User::config('db_path'));
         User::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         User::$db->exec('PRAGMA foreign_keys = ON');
     }
     return User::$db;
 }
Example #7
0
 protected function db()
 {
     if (isset(self::$db)) {
         return self::$db;
     }
     $path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . self::filename;
     $db = new PDO('sqlite2:' . $path, NULL, NULL, array(PDO::ATTR_PERSISTENT => TRUE));
     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return self::$db = $db;
 }