Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Connect{
- private $host = "localhost";
- private $db = "matematyka";
- private $user = "root";
- private $password = "";
- public function setConnect($host, $db, $user, $password){
- $this->host = $host;
- $this->db = $db;
- $this->user = $user;
- $this->password = $password;
- }
- public function getConnect(){
- return $conn = new PDO('mysql:host='.$this->host.';dbname='.$this->db.'',$this->user,$this->password);
- }
- }
- class QueryDB extends Connect{
- private $result;
- private $obj;
- public function setQueryDB($result,$obj){
- $this->result = $result;
- $this->obj = $obj;
- }
- public function getQueryDB(){
- $this->result = $this->getConnect()->query("SELECT * FROM liczby");
- $this->obj = $this->result -> fetch(PDO::FETCH_OBJ);
- return $this->obj;
- }
- }
- $test = new QueryDB;
- $test->getQueryDB();
- /*
- $conn = new PDO(
- 'mysql:host=localhost;dbname=matematyka','root',''
- );
- $result = $conn -> query("SELECT * FROM liczby");
- $obj = $result -> fetch(PDO::FETCH_OBJ);
- function addition($number1,$number2){
- return $number1 + $number2;
- }
- */
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8" />
- </head>
- <body>
- Dodawanie liczb:<br />
- <?php ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement