Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('DB_HOST', 'localhost'); # host bazy danych
- define('DB_PORT', 3306); # port bazy danych
- define('DB_USER', ''); # użytkownik bazy danych
- define('DB_NAME', ''); # nazwa bazy danych
- define('DB_PASS', ''); # hasło bazy danych
- class Database
- {
- private $host = DB_HOST;
- private $user = DB_USER;
- private $pass = DB_PASS;
- private $dbname = DB_NAME;
- function __construct()
- {
- $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
- $options = array(
- PDO::ATTR_PERSISTENT => true,
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
- );
- try{
- $this->db = new PDO($dsn, $this->user, $this->pass, $options);
- }
- catch(PDOException $e){
- exit('Brak polaczenia z baza danych.');
- }
- }
- }
- class Tools extends Database
- {
- public function Records( $default )
- {
- $query = $this->db->prepare("SELECT * FROM `mecze` WHERE `league_id`= :league_id");
- $query->bindValue(':league_id', $default, PDO::PARAM_INT);
- $query->execute();
- $list = $query->fetchAll(PDO::FETCH_ASSOC);
- $query->closeCursor();
- }
- public function Update( $title, $logo, $status, $points_plus, $done_matches, $points2_plus, $points2_minus, $diff, $league_id )
- {
- $query = $this->db->prepare( 'UPDATE `mecze` SET `title` = :title WHERE `id`= :userid' );
- $query->bindValue( ':title', $title, PDO::PARAM_STR );
- $query->bindValue( ':logo', $logo, PDO::PARAM_STR );
- $query->bindValue( ':status', $status, PDO::PARAM_STR );
- $query->bindValue( ':points_plus', $points_plus, PDO::PARAM_STR );
- $query->bindValue( ':done_matches', $done_matches, PDO::PARAM_STR );
- $query->bindValue( ':points2_plus', $points2_plus, PDO::PARAM_STR );
- $query->bindValue( ':points2_minus', $points2_minus, PDO::PARAM_STR );
- $query->bindValue( ':diff', $diff, PDO::PARAM_STR );
- $query->bindValue( ':league_id', $league_id, PDO::PARAM_STR );
- $query->execute();
- $count = $query->rowCount();
- $query->closeCursor();
- if($count > 0) return true;
- }
- }
- // zastosowanie Records
- foreach( $obiekt->Records(6) as $var )
- {
- print_r($var);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement