public static function deleteIgralec($id) { $db = DBInit::getInstance(); $statement = $db->prepare("DELETE FROM igralec WHERE id = :id"); $statement->bindParam(":id", $id, PDO::PARAM_INT); $statement->execute(); }
/** * Vrne referenco na instanco razreda PDO za dostop do baze. Privzeto se * instanca pridobi z metodo DB::getInstance(), lahko pa jo tudi nastavimo * sami z metodo self::setConnection($dbh). * * @return type PDO */ public static function getConnection() { if (is_null(self::$dbh)) { self::$dbh = DBInit::getInstance(); } return self::$dbh; }
public static function addVehicle($vname) { $db = DBInit::getInstance(); $statement = $db->prepare("INSERT INTO vehicle (vehiclename) VALUES (:vname)"); $statement->bindParam(":vname", $vname); $statement->execute(); }
public static function getByKategorija($kategorija) { $db = DBInit::getInstance(); $statement = $db->prepare("SELECT * FROM tekma WHERE kategorija = :kategorija"); $statement->bindParam(":kategorija", $kategorija, PDO::PARAM_STR); $statement->execute(); return $statement->fetchAll(); }
public static function preveriUporabnika($username) { $db = DBInit::getInstance(); $statement = $db->prepare("SELECT COUNT(id) AS koliko FROM uporabnik WHERE username = :username"); $statement->bindParam(":username", $username, PDO::PARAM_STR); $statement->execute(); return $statement->fetch(); }
public static function search($query) { $db = DBInit::getInstance(); $statement = $db->prepare("SELECT IDStation, name, Lat,Lng FROM TrainStations WHERE MATCH (IDStation,Name) AGAINST (:query IN BOOLEAN MODE)"); $statement->bindValue(":query", $query); $statement->execute(); return $statement->fetchAll(); }
public static function getInstance() { if (!self::$instance) { $config = "mysql:host=" . self::$host . ";dbname=" . self::$schema; $options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); self::$instance = new PDO($config, self::$user, self::$password, $options); } return self::$instance; }
public static function insertData($miles, $gas, $uid) { $db = DBInit::getInstance(); $statement = $db->prepare("INSERT INTO data (miles, fuelup, user_iduser) VALUES (:miles, :gas, :uid)"); $statement->bindParam(":uid", $uid); $statement->bindParam(":miles", $miles); $statement->bindParam(":gas", $gas); $statement->execute(); }
public static function addComment($user, $text, $commentator) { $db = DBInit::getInstance(); $statement = $db->prepare("INSERT INTO comments (text, commentator, user_iduser) VALUES (:text, :commentator, :user)"); $statement->bindParam(":user", $user); $statement->bindParam(":text", $text); $statement->bindParam(":commentator", $commentator); $statement->execute(); }
public static function insert($kdo, $token, $ip, $kdaj) { $db = DBInit::getInstance(); $statement = $db->prepare("INSERT INTO vpis (uporabnik, token, ip, time) VALUES (:kdo, :token, :ip, :kdaj)"); $statement->bindParam(":kdo", $kdo, PDO::PARAM_STR); $statement->bindParam(":token", $token, PDO::PARAM_STR); $statement->bindParam(":ip", $ip, PDO::PARAM_STR); $statement->bindParam(":kdaj", $kdaj, PDO::PARAM_STR); $statement->execute(); }
public static function addUser($username, $email, $fullname, $password, $vehicle) { $db = DBInit::getInstance(); $status = 'D'; $statement = $db->prepare("INSERT INTO user (username, email, fullname, password, vehicle_idvehicle, status) VALUES (:username, :email, :fullname, :password, :vehicle, :status)"); $statement->bindParam(":username", $username); $statement->bindParam(":email", $email); $statement->bindParam(":fullname", $fullname); $statement->bindParam(":password", $password); $statement->bindParam(":vehicle", $vehicle); $statement->bindParam(":status", $status); $statement->execute(); }
/** * Created by PhpStorm. * User: klemenkozelj * Date: 13/11/15 * Time: 11:13 */ require_once "DBInit.php"; $conn; $get = $_GET["geoData"]; $criminal = $_GET["criminal"]; $marriagedivorce = $_GET["marriagedivorce"]; $population = $_GET["population"]; $avgage = $_GET["avgage"]; if (!isset($conn)) { $conn = DBInit::init(); } if (isset($get)) { if (strcmp($get, "getAll") === 0) { $result = DBinit::getIDsNames($conn); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo $row["IDObcina"] . "&" . $row["ImeObcine"] . "&" . $row["LngLat"] . PHP_EOL; } } } else { $result = DBinit::getRowWithParam($conn, $get); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo $row["IDObcina"] . "&" . $row["ImeObcine"] . "&" . $row["LngLat"]; }
public static function searchtoken($username) { $db = DBInit::getInstance(); $statement = $db->prepare("SELECT WHERE MATCH (IDStation,Name) AGAINST (:query IN BOOLEAN MODE)"); $statement->bindValue(":query", $query); $statement->execute(); return $statement->fetchAll(); }
<?php require_once 'User.php'; require_once 'db_init.php'; $isPost = filter_input(INPUT_SERVER, 'REQUEST_METHOD') == 'POST'; $invalid = TRUE; $message = "Invalid input!"; if ($isPost) { $rules = array('password' => array('filters' => FILTER_SANITIZE_SPECIAL_CHARS, 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z0-9_-]{6,18}\$/")), 'username' => array('filters' => FILTER_SANITIZE_SPECIAL_CHARS, 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array("regexp" => "/^[a-zA-Z0-9_-]{5,16}\$/"))); $sent = filter_input_array(INPUT_POST, $rules); if ($sent["username"] != FALSE && $sent["password"] != FALSE) { try { $dbh = DBInit::getInstance(); $stmt = $dbh->prepare("SELECT * FROM user WHERE username = ?"); $stmt->bindValue(1, $sent["username"]); $stmt->execute(); $db = $stmt->fetch(); if (password_verify($sent["password"], $db["password"]) && $db["status"] == 'A') { setcookie("user", $db["username"], time() + 3600 * 24 * 30, "/"); header("Location: ../index.php"); } else { if (password_verify($sent["password"], $db["password"]) && $db["status"] == 'G') { setcookie("admin", $db["username"], time() + 3600 * 24 * 30, "/"); header("Location: ../html/admin.php"); } else { $message = "Username and password are not valid!"; } } } catch (PDOException $e) { die($e->getMessage()); }
public static function findNarocila($stanje) { $db = DBInit::getInstance(); $statement = $db->prepare("SELECT id_narocila, id_stranke,datum,stanje FROM narocila\n WHERE stanje=:stanje"); $statement->bindParam(":stanje", $stanje); $statement->execute(); return $statement->fetchAll(); }