示例#1
0
 /**
  *  @method getDSN
  *  @return string
  */
 public function getDSN()
 {
     switch ($this->driver) {
         case self::MYSQL:
             $this->DSN = 'mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/db');
             break;
         case self::POSTGRESQL:
             $this->DSN = 'pgsql:dbname=' . Config::get('mysql/db') . ';host=' . Config::get('mysql/host');
             break;
         case self::SQLITE:
             $this->DSN = 'sqlite:' . Config::get('mysql/db');
             break;
         case self::MARIADB:
             break;
         default:
             break;
     }
     return $this->DSN;
 }
示例#2
0
 /**
  *  @method default constructor
  *  @access private
  *  @note uses singleton pattern so only one instance of our database is used for all queries and connections...
  *  @note host, db, username, and password are all supplied by the Config::get method getting data from our gloBal config array defined in Core/init.php
  */
 private function __construct()
 {
     $this->dbDriver = new DBDriver(Config::get('mysql/driver'));
     $this->queryType = self::QUERY_TYPE_SELECT;
     try {
         $this->pdo = new PDO($this->dbDriver->getDSN(), Config::get('mysql/username'), Config::get('mysql/password'));
     } catch (\PDOException $e) {
         die($e->getMessage());
     }
 }
示例#3
0
 /**
  * @param Form $form
  * @param $errors
  */
 public function checkFormErrors(Form $form, $errors)
 {
     foreach ($form->getElements() as $element) {
         if (isset($errors[$element->getAttribute('name')])) {
             $element->addClass(Config::get('validation/error-class'));
         }
     }
 }