public static function getInstance($arg) { if (!self::$instance instanceof self) { self::$instance = new self($arg); } return self::$instance; }
static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public function closeConnection() { if (self::$instance) { self::$instance = null; unset(self::$instance); } }
public static function getInstance() { if (self::$instance == null) { self::$instance = new DB(); } return self::$instance; }
protected static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
public static function Conn() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance->db; }
function __construct($host, $name, $user, $pass) { if (!self::testConnection($host, $name, $user, $pass)) { $dbms_database_open = false; } else { $dbms_database_open = true; $this->host = $host; $this->name = $name; $this->user = $user; $this->pass = $pass; } $result = mysql_query("SHOW TABLES FROM {$this->name}"); while ($row = mysql_fetch_row($result)) { $this->tables[] = strtolower($row[0]); } foreach ($this->tables as $k => $tableName) { $oid = mysql_query("SHOW COLUMNS\n\t\t\t\t\t\tFROM {$tableName}"); if (!$oid) { echo Message::getInstance()->getMessage(MSG_ERROR_DATABASE_GENERIC) . " (" . basename(__FILE__) . ":" . __LINE__ . ")"; exit; } do { $data = mysql_fetch_assoc($oid); if ($data) { $this->fields[$tableName][$data['Field']] = true; } } while ($data); } self::$instance = $this; }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public function index() { #$this->template->content = View::instance('v_users_signup'); $q = "SHOW TABLES"; #$tableDump = DB::instance(DB_NAME)->select_rows($q); #array(3) { # [0]=> array(1) { ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "posts" } # [1]=> array(1) { ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "users" } # [2]=> array(1) { ["Tables_in_rtizardc_p2_rtizard_com"]=> string(11) "users_users" } } $tableDump = DB::instance(DB_NAME)->select_rows($q, "array"); #array(3) #{ [0]=> array(2) { [0]=> string(5) "posts" ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "posts" } #[1]=> array(2) { [0]=> string(5) "users" ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "users" } #[2]=> array(2) { [0]=> string(11) "users_users" ["Tables_in_rtizardc_p2_rtizard_com"]=> string(11) "users_users" } } #$this->template->content = var_dump($tableDump); $i = 0; $tableArray = array(); foreach ($tableDump as $row) { #echo $row[0].", "; $tableArray[$i] = $row[0]; $i++; } $this->template->content = View::instance('v_data_index'); $this->template->content->tableArray = $tableArray; #$this->template->content = var_dump($tableArray); $this->template->title = "Data"; # Render template echo $this->template; }
public function p_signup() { # Check if data was entered if ($_POST['first_name'] == "" || $_POST['last_name'] == "" || $_POST['password'] == "") { # Send back to signup with appropriate error Router::redirect("/users/signup/Please enter all requested information"); } # Check if email address is of the right form if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { # Send back to signup with appropriate error Router::redirect("/users/signup/Please enter a valid email address"); } # Check if passwords match if ($_POST['password'] != $_POST['password_check']) { # Send back to signup with appropriate error Router::redirect("/users/signup/Passwords do not match"); } # Remove the password check from the array unset($_POST['password_check']); # Encrypt the password $_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']); # More data we want stored with the user $_POST['created'] = Time::now(); $_POST['modified'] = Time::now(); $_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string()); # Insert this user into the database $user_id = DB::instance(DB_NAME)->insert("users", $_POST); # Send the user to the signup success page $this->template->content = View::instance('v_users_signup_success'); $this->template->title = "Success!"; echo $this->template; }
public static function get() { if (is_null(self::$instance)) { self::$instance = new DB(); } return self::$instance; }
private static function gi() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * @return DB */ static function getConn() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (!self::$instance) { self::$instance = new PDO(DSN, USER, PASS); } return self::$instance; }
public function instance($host = null, $user = null, $pwd = null, $db = null) { if (self::$instance != null) { return self::$instance; } return self::$instance = new DB($host, $user, $pwd, $db); }
public function createAccount(array $data) { $db = DB::instance()->prepare('INSERT INTO `users` SET `name`=:name, `password`=:pass'); $db->bindValue(':name', $data['name'], PDO::PARAM_STR); $db->bindValue(':pass', Auth::instance()->encodePassword($data['password']), PDO::PARAM_STR); $db->execute(); }
public static function getInstance() { if (DB::$instance == null) { DB::$instance = new DB(); } return DB::$instance->connexion; }
private function postConstruct() { $this->db = DB::instance(); I18N::instance()->addFolder('i18n'); UserHandler::instance(); $this->controller = Controller::instance(); }
public function findAssoc($conditions = null) { list($left, $left_model, $left_columns) = static::_joinConfigIndexed(static::$CONFIG_LEFT, 'left'); list($right, $right_model, $right_columns) = static::_joinConfigIndexed(static::$CONFIG_RIGHT, 'right'); $cols = array_merge($left_columns, $right_columns); return DB::instance()->join($left, $right, static::$JOIN_TYPE, $conditions, $cols); }
public function __construct($user = null) { $this->_db = DB::instance(); $this->_config = new Config(); if (!$user) { if (isset($_SESSION['uid'])) { $user = $_SESSION['uid']; if ($this->find($user) && $this->validate()) { $hash = Hash::unique(); if (isset($_COOKIE['uniqid'])) { $qr = $this->_db->get("session", ["hash", "=", $_COOKIE['uniqid']]); if (!$qr->count()) { setcookie("uniqid", $hash, 2147483647); $this->_db->insert("session", ["uid" => $_SESSION['uid'], "hash" => $hash, "ip" => $_SERVER['REMOTE_ADDR']]); } } else { setcookie("uniqid", $hash, 2147483647); $this->_db->insert("session", ["uid" => $_SESSION['uid'], "hash" => $hash, "ip" => $_SERVER['REMOTE_ADDR']]); } $this->_loggedIn = true; } else { self::logout(); } } elseif (isset($_COOKIE['uniqid'])) { $qr = $this->_db->get("session", ["hash", "=", $_COOKIE['uniqid']]); if ($qr->count() && $qr->first()->ip == $_SERVER['REMOTE_ADDR']) { self::login($qr->first()->uid); } } } else { $this->find($user); } }
public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
public function __construct($route) { global $routes, $config, $user; $db = DB::instance(); $routing = explode("/", rtrim($route, "/")); $query = array_splice($routing, 1); $routing = array_filter($routing); $routing = strtolower(trim(isset($routing[0]) ? $routing[0] : "")); $query = array_filter($query); if ($user->loggedIn()) { $db->update("user", ["id", "=", $user->data()->id], ["last_active" => date("Y-m-d H:i:s", time()), "last_visited" => array_key_exists($routing, $routes) ? $routing : ($routing == 'index' ? 'index' : 'unknown')]); } if (empty($routing)) { req("index.php", $query); } else { if (!array_key_exists($routing, $routes) && $routing != "index") { die(include_once "../route/404.php"); } elseif ($routing == "index") { req("index.php", $query); } else { $f = $routes[$routing]; if (is_callable($f)) { call_user_func($f); } else { req($f, $query); } } } }
public static function getInstance() { if (!self::$instance) { self::$instance = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE_NAME); } return self::$instance; }
public static function sidenav($get) { $navin = DB::instance()->get("navigation"); $navout = array(); foreach ($navin->results() as $row) { if ($row->url == '%SUBJECTS%') { $row = self::parseSubjectNav($row); } if (!empty($row->sub_names)) { $subNames = explode(',', str_replace(', ', ',', $row->sub_names)); $subUrls = explode(',', str_replace(', ', ',', $row->sub_urls)); $active = false; $subItems = array(); foreach ($subNames as $index => $subName) { $activeSub = self::isActive($get, $subUrls[$index]); if ($activeSub) { $active = true; } $subItems[] = array("title" => $subName, "location" => $subUrls[$index], "active" => $activeSub); } if ($active) { $navout[] = array("header" => $row->header, "content" => $subItems); } } } return $navout; }
public static function getInstance() { if (!self::$instance) { self::$instance = new mysqli("localhost", "root", "", "musicstore"); } return self::$instance; }
public static function init(array $dbOptions) { if (self::$instance instanceof self) { return false; } self::$instance = new self($dbOptions); }
public static function init() { if (self::$instance instanceof self) { return false; } self::$instance = new self(); }
public static function getInstance() { if (self::$instance === NULL) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new DB(); } return self::$instance; }
public static function getInstance() { if (DB::$instance == null) { DB::$instance = new DB(Config::HOST, Config::USERNAME, Config::PASSWORD, Config::DATABASE_NAME); } return DB::$instance; }