function __construct()
 {
     // opening db connection
     $db = new DbConnect();
     $this->conn = $db->connect();
     //$this->echoAllConstituentNames();
 }
 function __construct()
 {
     require_once 'dbconn.php';
     // CONNESSIONE
     $db = new DbConnect();
     $this->conn = $db->connect();
 }
Exemple #3
0
 function getAllBirthdays()
 {
     $conn = new DbConnect();
     $query = $conn->getHandler()->query("SELECT * FROM dinosaur");
     $result = $query->fetchAll(PDO::FETCH_ASSOC);
     return $result;
 }
Exemple #4
0
 function __construct()
 {
     require_once dirname(__FILE__) . '/DbConnect.php';
     // opening db connection
     $db = new DbConnect();
     $this->conn = $db->connect();
 }
Exemple #5
0
 function __construct()
 {
     require_once dirname(__FILE__) . '/DbConnect.php';
     // Abrimos la conexxion a la BD
     $db = new DbConnect();
     $this->conn = $db->connect();
 }
Exemple #6
0
 function __construct()
 {
     $this->columns = array();
     require_once 'config/DbConnect.php';
     // opening db connection
     $db = new DbConnect();
     $this->conn = $db->connect();
 }
Exemple #7
0
 public function __construct()
 {
     for ($i = 1; $i <= $this->getInitialSize(); $i++) {
         $dbConnect = new DbConnect();
         $dbConnect->setCreated(time());
         $this->addConnect($dbConnect);
     }
 }
Exemple #8
0
 function __construct()
 {
     require_once dirname(__FILE__) . '/db_connect.php';
     require_once dirname(__FILE__) . '/mail/class.phpmailer.php';
     require_once dirname(__FILE__) . '/mail/class.smtp.php';
     // opening db connection
     $db = new DbConnect();
     $this->conn = $db->connect();
 }
 function __construct()
 {
     require_once dirname(__FILE__) . '/DbConnect.php';
     //open new database
     try {
         $db = new DbConnect();
         //instantiate the DbConnect class
         $this->conn = $db->connect();
     } catch (PDOException $ex) {
         $this::dbConnectError($ex->getCode());
     }
 }
Exemple #10
0
 function __construct()
 {
     require_once dirname(__FILE__) . '/DbConnect.php';
     //open new database connection
     try {
         $db = new DbConnect();
         //instantiate the DbConnect class
         $this->conn = $db->connect();
     } catch (Exception $ex) {
         $this::dbConnectError($ex->getCode());
         exit;
         //unconditionally stop processing
     }
 }
 function __construct()
 {
     require_once dirname(__FILE__) . '/DbConnect.php';
     // abriendo conexión
     $db = new DbConnect();
     $this->conn = $db->connect();
     session_start();
     if (isset($_SESSION['user'])) {
         $user_logged_in = true;
     }
     if (isset($_SESSION['copisteria'])) {
         $copisteria_logged_in = true;
     }
 }
 public function getSubcategory($id)
 {
     $connection = new DbConnect();
     $pdo = $connection->connect();
     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $query = "select * from subcategories\n                  where id = :id";
     $stmt = $pdo->prepare($query);
     $stmt->bindParam(':id', $id);
     $stmt->setFetchMode(PDO::FETCH_CLASS, 'Subcategory');
     $stmt->execute();
     $subcategory = $stmt->fetch();
     return $subcategory;
     //return $this;
 }
Exemple #13
0
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public static function get()
 {
     if (!isset(self::$instance)) {
         self::$instance = new DbConnect();
     }
     return self::$instance;
 }
 private function getContacts()
 {
     $this->table = 'contacts';
     //Select query
     $this->query_string = "SELECT * FROM %s WHERE user_id = '%s'";
     //Package array for query arguments
     $this->packageArguments();
     //Connect to database
     $this->db = DbConnect::get();
     //Query db
     $this->result = $this->db->query($this->query_string, $this->arguments);
     //Reset Session
     $this->contacts_array = array();
     //Turn result into associative array
     if (mysql_num_rows($this->result)) {
         while ($this->contacts = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
             $this->contact = array('contact_id' => $this->contacts['id'], 'first_name' => $this->contacts['first_name'], 'last_name' => $this->contacts['last_name'], 'phone_one' => $this->contacts['phone_one'], 'phone_two' => $this->contacts['phone_two'], 'phone_three' => $this->contacts['phone_three'], 'email' => $this->contacts['email'], 'company' => $this->contacts['company'], 'address_one' => $this->contacts['address_one'], 'address_two' => $this->contacts['address_two'], 'city' => $this->contacts['city'], 'state' => $this->contacts['state'], 'zip_code' => $this->contacts['zip_code'], 'notes' => $this->contacts['notes']);
             array_push($this->contacts_array, $this->contact);
         }
         return $this->contacts_array;
     } else {
         $this->error_message = "You have No Contacts";
         return $this->error_message;
     }
 }
 public static function delete($id)
 {
     $pdo = DbConnect::connect();
     $sql = "DELETE from abteilung WHERE id=:id";
     $stmt = $pdo->prepare($sql);
     $stmt->execute([':id' => $id]);
 }
Exemple #17
0
 public static function getInstance()
 {
     if (!self::$_instance) {
         // If no instance then make one
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #18
0
 public function __construct()
 {
     $db = DbConnect::getInstance();
     $this->conn = $db->getConnection();
     if (!$this->conn) {
         throw new Exception("cannot connect to server");
     }
     return $this->conn;
 }
 public function __construct()
 {
     $this->user_name = $_SESSION['current_user'];
     //Connect to database
     $this->db = DbConnect::get();
     //$this->endConvo();
     //$this->deleteMessages();
     $this->logout();
     $this->endSession();
 }
Exemple #20
0
    public static function getInstance()
    {
        if(self::$instance == null)
        {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
    }
 public static function getConnection($reuse = true)
 {
     if (!DbConnect::$db || !$reuse) {
         $db = mysqli_connect(Options::$DBHOST, Options::$DBUSER, Options::$DBPASSWORD, Options::$DBNAME);
         if (!$db) {
             die(mysqli_connect_error());
         }
         mysqli_set_charset($db, "UTF8");
         DbConnect::$db = $db;
     }
     return DbConnect::$db;
 }
 /**
  * 
  * @return object PDO connection
  */
 public static function MySqlConnecton($config)
 {
     if (is_null(self::$MySql)) {
         //переменная $connectionStr содержит настройки для подключения к базе данных -
         //рецепиенту TecDoc - tecdoc(MySQL)
         $connectionStr = 'mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'];
         $user = $config['user'];
         $password = $config['password'];
         $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
         self::$MySql = new PDO($connectionStr, $user, $password, $options);
     }
     return self::$MySql;
 }
 public static function getAll()
 {
     $pdo = DbConnect::connect();
     $sql = "SELECT mit.vorname vorname, mit.nachname nachname, abt.name abteilung, CONCAT(vor.vorname, ' ', vor.nachname) vorgesetzter\r\n                FROM abteilung abt\r\n                LEFT JOIN mitarbeiter mit ON mit.abteilung_id=abt.id\r\n                LEFT JOIN mitarbeiter vor ON mit.vorgesetzter_id=vor.id";
     $stmt = $pdo->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     //        echo '<pre>';
     //        print_r($rows);
     //        echo '</pre>';
     //        die();
     //        echo 'Start';
     return $rows;
 }
 public static function getAll()
 {
     $pdo = DbConnect::connect();
     $sql = "SELECT CONCAT(her.name, ' ', a.name, ' ', a.kennzeichen) Fahrzeug, CONCAT(mit.vorname, ' ', mit.nachname) Ausleiher, aus.von Von, aus.bis Bis\r\n                FROM auto a, hersteller her, mitarbeiter mit, ausleihe aus\r\n                WHERE aus.auto_id=a.id AND a.hersteller_id=her.id AND aus.mitarbeiter_id=mit.id;";
     $stmt = $pdo->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     //        echo '<pre>';
     //        print_r($rows);
     //        echo '</pre>';
     //        die();
     //        echo 'Start';
     return $rows;
 }
 public static function getAll()
 {
     $pdo = DbConnect::connect();
     $sql = "SELECT abt.name Abteilung, CONCAT(mit.vorname, ' ', mit.nachname) Ausleiher, aus.von Von, aus.bis Bis\n                FROM abteilung abt, mitarbeiter mit, ausleihe aus\n                WHERE mit.abteilung_id=abt.id AND aus.mitarbeiter_id=mit.id;";
     $stmt = $pdo->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     //        echo '<pre>';
     //        print_r($rows);
     //        echo '</pre>';
     //        die();
     //        echo 'Start';
     return $rows;
 }
Exemple #26
0
 public static function getInstance()
 {
     //configuration parameters:
     $config_params = Config::getConfigParams();
     $hostdb = $config_params['hostdb'];
     $database = $config_params['database'];
     $pwdb = $config_params['pwdb'];
     $userdb = $config_params['userdb'];
     if (self::$db == null) {
         //self::$db = new mysqli("173.201.217.33", "twetest", "Spearmint1", "twetest");
         self::$db = new mysqli($hostdb, $database, $pwdb, $userdb);
     }
     return self::$db;
 }
 public static function getAll()
 {
     $pdo = DbConnect::connect();
     $sql = "SELECT projekt.name Projektname, CONCAT(mitarbeiter.vorname,' ', mitarbeiter.nachname) Mitarbeiter, HOUR(TIMEDIFF(projektmitarbeiter.von, projektmitarbeiter.bis)) Stunden \r\n                FROM projekt, projektmitarbeiter, mitarbeiter \r\n                WHERE projektmitarbeiter.projekt_id=projekt.id AND mitarbeiter.id = projektmitarbeiter.mitarbeiter_id;";
     $stmt = $pdo->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     //        echo '<pre>';
     //        print_r($rows);
     //        echo '</pre>';
     //        die();
     //        echo 'Start';
     return $rows;
 }
 public static function connect()
 {
     /*
      * Design Pattern: Singleton
      * wenn die Verbindung zur db schon vorhanden ist
      * soll Methode connect() eine Verbindung nicht nochmal
      * erstellen, also max Anzahl Connections = 1
      */
     if (!self::$conn) {
         try {
             self::$conn = new PDO('mysql:host=' . DB_SERVER . ';charset=utf8' . ';dbname=' . DB_NAME, DB_USER, DB_PASSWD, [PDO::ATTR_PERSISTENT => TRUE, PDO::ATTR_ERRMODE => TRUE, PDO::ATTR_EMULATE_PREPARES => FALSE]);
         } catch (Exception $exc) {
             throw new Exception('Konnte mich nicht mit db verbinden DB_SERVER:' . DB_SERVER . ' oder SQL Fehler ->phplogger.txt');
         }
     }
     return self::$conn;
 }
 private function handleInfo()
 {
     //If no errors, query db
     if (!isset($this->error_message)) {
         //Update query
         $this->query_string = "UPDATE %s SET first_name = '%s', last_name = '%s', phone_one = '%s', phone_two = '%s', phone_three = '%s', email = '%s', company = '%s', address_one = '%s', address_two = '%s', city = '%s', state = '%s', zip_code = '%s', notes = '%s', user_id = '%s' WHERE id = '%s';";
         //Package array for query arguments
         $this->packageEditArguments();
         //Connect to database
         $this->db = DbConnect::get();
         //call query method
         $this->result = $this->db->query($this->query_string, $this->arguments);
         $this->return_array = array('id' => $this->real_contact_id, 'errorMessage' => NULL);
         //If errors, set session and redirect
     } else {
         $this->return_array = array('id' => $this->real_contact_id, 'errorMessage' => $this->error_message);
     }
 }
 private function handleInfo()
 {
     //If no errors, query db
     if (!isset($this->errorMsg)) {
         $this->first_name = $this->postArray['First Name'];
         $this->user_name = $this->postArray['User Name'];
         $this->password = $this->postArray['Password'];
         $this->table = "users";
         $this->logged_in = "0";
         //Encrypt login
         $this->encryptLogin();
         //Select query
         $this->query_string = "SELECT * FROM %s WHERE user_name = '%s'";
         //Package array for query arguments
         $this->packageArguments();
         //Connect to database
         $this->db = DbConnect::get();
         //call query method
         $this->result = $this->db->query($this->query_string, $this->arguments);
         //Turn result into associative array
         $this->line = mysql_fetch_array($this->result, MYSQL_ASSOC);
         //Check to see if user name already exists and redirect, else create new user
         if ($this->line) {
             $this->errorMsg .= 'User Name Already Exists';
             $_SESSION['error'] = $this->errorMsg;
             header("Location: ../index.php");
         } else {
             //Select query
             $this->query_string = "INSERT INTO %s (first_name, user_name, password, logged_in) VALUES('%s', '%s', '%s', '%s');";
             //Package array for query arguments
             $this->packageInsertArguments();
             //call query method
             $this->result = $this->db->query($this->query_string, $this->arguments);
             $this->errorMsg .= 'Account Created, Please Log in';
             $_SESSION['error'] = $this->errorMsg;
             header("Location: ../index.php");
         }
         //If errors, set session and redirect
     } else {
         $_SESSION['error'] = $this->errorMsg;
         header("Location: ../index.php");
     }
 }