Example #1
0
 /**
  * @return null
  */
 public function setUp()
 {
     $this->runDbStartupTask();
     $connector = DbRegistry::getConnector('af-tester');
     $this->conn = $connector->getConnection();
     $this->conn->connect();
     $driver = $this->conn->getDriver();
     $this->stmtDriver = $driver->stmt_init();
     $this->stmt = new PreparedStmt($this->stmtDriver);
 }
 /**
  * connect()
  */
 public function connect($dsninfo, $flags = 0)
 {
     if (!($driver = Creole::getDriver($dsninfo['phptype']))) {
         throw new SQLException("No driver has been registered to handle connection type: {$type}");
     }
     $connectionClass = Creole::import($driver);
     $this->childConnection = new $connectionClass();
     $this->log("connect(): DSN: " . var_export($dsninfo, true) . ", FLAGS: " . var_export($flags, true));
     return $this->childConnection->connect($dsninfo, $flags);
 }
Example #3
0
 public function testConnection()
 {
     $this->subject->disconnect();
     $result = $this->subject->connect();
     $this->assertTrue($result);
     // Try a reconnect
     $result = $this->subject->connect();
     $this->assertTrue($result);
     $result = $this->subject->isConnected();
     $this->assertTrue($result);
     $result = $this->subject->disconnect();
     $this->assertTrue($result);
     $result = $this->subject->isConnected();
     $this->assertFalse($result);
 }
Example #4
0
 public function setNewSport($cz)
 {
     $db = parent::connect();
     $result = $db->prepare("INSERT INTO `sport`(`cz`) VALUES ( ? )");
     $result->execute(array($cz));
     return $db->lastInsertId();
 }
Example #5
0
 public function getAllEntryForAuthor($author)
 {
     $result = parent::connect()->prepare("SELECT * FROM `entries` WHERE `author` = :id AND `active` = 1 ORDER BY `id` DESC");
     $result->execute(array(':id' => $author));
     $pageResult = $result->fetchAll();
     return $pageResult;
 }
Example #6
0
 protected function setUp()
 {
     $host = getenv('TEST_BEANSTALKD_HOST');
     $port = getenv('TEST_BEANSTALKD_PORT');
     if (!$host || !$port) {
         $message = 'TEST_BEANSTALKD_HOST and/or TEST_BEANSTALKD_PORT env variables not defined.';
         $this->markTestSkipped($message);
     }
     $connection = new Connection($host, $port, false);
     if (!$connection->connect()) {
         $message = "Need a running beanstalkd server at {$host}:{$port}.";
         $this->markTestSkipped($message);
     }
     $this->subject = new Client($connection);
     // Clear all jobs on the server
     foreach ($this->subject->listTubes() as $tube) {
         $this->subject->useTube($tube);
         while ($job = $this->subject->peekReady()) {
             $this->subject->delete($job['id']);
         }
         while ($job = $this->subject->peekBuried()) {
             $this->subject->delete($job['id']);
         }
     }
     $this->subject->useTube('default');
 }
Example #7
0
 public function setNewImg($name, $size, $user, $type)
 {
     $db = parent::connect();
     $timestamp = time();
     $result = $db->prepare("INSERT INTO `profile_image`(`name`, `timestamp`, `size`, `user`, `type`) VALUES (?, ?, ?, ?, ?)");
     $result->execute(array($name, $timestamp, $size, $user, $type));
 }
function posicionaApps($conf_apps)
{
    $colunas = explode('|', $conf_apps);
    foreach ($colunas as $chave => $coluna) {
        $apps = explode(',', $coluna);
        // Carrega estrutura HTML auxiliar
        if ($chave == 0) {
            require_once 'assets/htmls_auxiliares/html_box-esquerdo.php';
        }
        if ($chave == 1) {
            require_once 'assets/htmls_auxiliares/html_box-meio.php';
        }
        if ($chave == 2) {
            require_once 'assets/htmls_auxiliares/html_box-direito.php';
        }
        // Carrega cada app separadamente
        $connect = Connection::connect();
        foreach ($apps as $app) {
            if (!empty($app)) {
                require 'apps/' . $app . '.php';
            }
        }
        // Carrega estrutura HTML auxiliar
        if ($chave == 0) {
            require_once 'assets/htmls_auxiliares/html_fim_box-esquerdo.php';
        }
        if ($chave == 1) {
            require_once 'assets/htmls_auxiliares/html_fim_box-meio.php';
        }
        if ($chave == 2) {
            require_once 'assets/htmls_auxiliares/html_fim_box-direito.php';
        }
    }
}
 private function tryMethod($method, $args)
 {
     try {
         return call_user_func_array([$this->connection, $method], $args);
     } catch (\Exception $exception) {
         $e = $exception;
         while ($e->getPrevious() && !$e instanceof \PDOException) {
             $e = $e->getPrevious();
         }
         if ($e instanceof \PDOException && $e->errorInfo[1] == self::MYSQL_CONNECTION_TIMED_WAIT_CODE) {
             $this->connection->close();
             $this->connection->connect();
             $this->logger->notice('Connection to MySQL lost, reconnect okay.');
             return call_user_func_array([$this->connection, $method], $args);
         }
         if (false !== strpos($exception->getMessage(), 'MySQL server has gone away') || false !== strpos($exception->getMessage(), 'Error while sending QUERY packet') || false !== strpos($exception->getMessage(), 'errno=32 Broken pipe')) {
             $this->connection->close();
             $this->connection->connect();
             $this->logger->notice('Connection to MySQL lost, reconnect okay.');
             return call_user_func_array([$this->connection, $method], $args);
         }
         $this->logger->critical('Connection to MySQL lost, unable to reconnect.', ['exception' => $exception]);
         throw $e;
     }
 }
Example #10
0
File: Auth.php Project: j3rin/Login
 function login($email, $password)
 {
     $mysqli = new Connection();
     $db = $mysqli->connect();
     //hash the password
     $password = hashPassword($password);
     //prepare the query
     $query = $db->prepare("SELECT id FROM users WHERE email = ? AND password = ? LIMIT 1") or die("error");
     $query->bind_param('ss', $email, $password);
     //excuting
     $query->execute();
     //store results
     $query->store_result();
     //bind results
     $query->bind_result($id);
     $query->fetch();
     //get the num rows
     if ($query->num_rows == 1) {
         $user_browser = $_SERVER['HTTP_USER_AGENT'];
         session_start();
         $_SESSION['login_string'] = array();
         $_SESSION['login_string']['browserInfo'] = hash('sha512', $user_browser);
         $_SESSION['login_string']['id'] = hash('sha512', $id);
         return TRUE;
     } else {
         return FALSE;
     }
     //close the query
     $db->close();
 }
Example #11
0
 public function getDBContent($page)
 {
     $result = parent::connect()->prepare("SELECT * FROM `pages` WHERE `url_name` = :page LIMIT 1");
     $result->execute(array(':page' => $page));
     $pageResult = $result->fetch();
     return $pageResult;
 }
Example #12
0
 public static function getConnection()
 {
     if (!isset(self::$connect)) {
         self::$connect = new Connection();
     }
     return self::$connect;
 }
Example #13
0
 public static function run()
 {
     Connection::connect();
     Session::start();
     Router::run();
     Connection::disconnect();
 }
Example #14
0
 public function getNahravkaAll()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `nahravka` ORDER BY `id` DESC");
     $result->execute(array());
     $nahravka = $result->fetchAll();
     return $nahravka;
 }
Example #15
0
 public function getEnroll($event)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `enroll` WHERE event = ?");
     $result->execute(array($event));
     $event = $result->fetchAll();
     return $event;
 }
Example #16
0
 public function showAllFriendsEntries($authors)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `entry` WHERE `author` IN (?) ORDER BY `timestamp` DESC");
     $result->execute(array(implode(", ", $authors)));
     $entry = $result->fetchAll();
     return $entry;
 }
Example #17
0
 public function getKontaktAll()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `kontakt`");
     $result->execute(array());
     $kontakt = $result->fetchAll();
     return $kontakt;
 }
Example #18
0
 public function getEntriesForEntry($id)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `forum_entry` WHERE replyToEntryNum  = ? AND active=1 ORDER BY `timestamp` DESC");
     $result->execute(array($id));
     $entries = $result->fetchAll();
     return $entries;
 }
Example #19
0
 public function getPopularItem()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `item` WHERE active=1 AND presentationImage!='' ORDER BY `prodanoObjednavek` DESC, `cenaSDPH` DESC LIMIT 9");
     $result->execute(array());
     $items = $result->fetchAll();
     return $items;
 }
Example #20
0
 public function getAllAkords()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `akord` ORDER BY `number` ASC");
     $result->execute(array());
     $akordy = $result->fetchAll();
     return $akordy;
 }
Example #21
0
 public function getAllItems()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `galerie` ORDER BY `likes` DESC, `timestamp` DESC");
     $result->execute(array());
     $items = $result->fetchAll();
     return $items;
 }
Example #22
0
 public function numOfComments($entry)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `comment_entry` WHERE `entry` = ? ORDER BY `timestamp` DESC");
     $result->execute(array($entry));
     $num = $result->rowCount();
     return $num;
 }
Example #23
0
 public function getPrihlasky($category)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `prihlasky` WHERE `kategorie` = ? ");
     $result->execute(array($category));
     $all = $result->fetchAll();
     return $all;
 }
Example #24
0
 public function getAllTrainingSport()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `training_sports`");
     $result->execute(array());
     $sport = $result->fetchAll();
     return $sport;
 }
Example #25
0
 public function getTitulek()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `titulek` limit 1");
     $result->execute(array());
     $titulek = $result->fetch();
     return $titulek;
 }
Example #26
0
 public function getDayInfo($user, $timestamp)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `intim_calendar` WHERE  `user` = ? && (`date` >= ? && `date` < ?) ");
     $result->execute(array($user, $timestamp, $timestamp + 86400));
     $events = $result->fetch();
     return $events;
 }
Example #27
0
 public function getItemById($id)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `store_Items` WHERE `id`=? ");
     $result->execute(array($id));
     $item = $result->fetch();
     return $item;
 }
Example #28
0
 public function getRealitiesOrderByPrice($level = 0, $order = 'DESC')
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `reality` WHERE (`level`<=? && `in_reality_store`=?) ORDER BY `price` {$order} ");
     $result->execute(array($level, 1));
     $items = $result->fetchAll();
     return $items;
 }
Example #29
0
 public function get3Clanek()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `clanek` ORDER BY `id` DESC limit 3");
     $result->execute(array());
     $clanek = $result->fetchAll();
     return $clanek;
 }
Example #30
0
 /**
  * @return null
  */
 public function testConnectClose()
 {
     $this->assertTrue($this->conn->connect());
     $this->assertEquals('connected', $this->conn->getStatus());
     $this->assertTrue($this->conn->isConnected());
     $this->assertFalse($this->conn->isError());
     $this->assertTrue($this->conn->close());
     $this->assertEquals('closed', $this->conn->getStatus());
     $this->assertFalse($this->conn->isDriver());
     $this->assertFalse($this->conn->isConnected());
     $this->assertFalse($this->conn->isError());
     /* lets see if we can connect again */
     $this->assertFalse($this->conn->connect());
     $this->assertEquals('closed', $this->conn->getStatus());
     $this->assertFalse($this->conn->isConnected());
     $this->assertTrue($this->conn->isError());
 }