private function loadDatabaseFromDbParsed()
 {
     if (is_array($this->credentials)) {
         $this->connection = new \PDO($this->credentials['sentencePdo'], $this->credentials['user'], $this->credentials['pass']);
     } else {
         $this->connection = new \PDO($this->credentials);
     }
     $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
 }
Пример #2
0
 public function ping()
 {
     if (empty($this->pdo) || $this->pdo instanceof \common\objdummy) {
         $this->pdo = $this->connect();
     } else {
         try {
             $status = $this->pdo->getAttribute(\PDO::ATTR_SERVER_INFO);
         } catch (\Exception $e) {
             if ($e->getCode() == 'HY000') {
                 $this->pdo = $this->connect();
             } else {
                 throw $e;
             }
         }
     }
     return $this->pdo;
 }
Пример #3
0
 /**
  * @return \Runalyze\Activity\PersonalBest this-reference
  */
 public function lookupWithDetails()
 {
     if (self::$USE_STATIC_CACHE && isset(self::$PBs[(double) $this->Distance]) && is_array(self::$PBs[(double) $this->Distance])) {
         $Data = self::$PBs[(double) $this->Distance];
     } else {
         $Data = $this->PDO->query('SELECT `id`, `s`, `time` FROM `' . PREFIX . 'training` ' . 'WHERE `typeid`="' . Configuration::General()->competitionType() . '" ' . 'AND `distance`="' . $this->Distance . '" ' . 'ORDER BY `s` ASC LIMIT 1')->fetch();
     }
     if (!empty($Data)) {
         $this->ActivityID = $Data['id'];
         $this->Timestamp = $Data['time'];
         $this->Time = $Data['s'];
         if (self::$USE_STATIC_CACHE) {
             self::$PBs[(double) $this->Distance] = $Data;
         }
     } else {
         $this->ActivityID = NULL;
         $this->Timestamp = NULL;
         $this->Time = false;
     }
     return $this;
 }
Пример #4
0
 /**
  * Performs sql sequence
  * 
  * @param string $sql
  * @param mixed $inputs_parameters Simple input parameter or array of inputs
  * @return PDOStatement
  */
 public function query($sql, $inputs_parameters = array())
 {
     $this->connect();
     if (!is_array($inputs_parameters)) {
         $inputs_parameters = array($inputs_parameters);
     }
     $query = $this->pdo->prepare($sql);
     $query->execute($inputs_parameters);
     return $query;
 }