Last active
January 12, 2016 12:19
-
-
Save VictorFursa/6977ef6e90d2903e4006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Db{ | |
| private $server = 'localhost'; | |
| private $userName = 'root'; | |
| private $passwrod = ''; | |
| private $select = 'catalog'; | |
| private $charset = "utf8"; | |
| private $sql = ""; | |
| function __construct(){ | |
| mysql_connect($this->server, $this->userName,$this->passwrod); | |
| mysql_select_db($this->select); | |
| mysql_set_charset($this->charset); | |
| $this->query($this->sql); | |
| $this->format($this->query($this->sql)); | |
| } | |
| function query($sql){ | |
| return mysql_query($sql); | |
| } | |
| function format($result){ | |
| $array = array(); | |
| while ($categories = mysql_fetch_array($result)) { | |
| $array[] = $categories; | |
| } | |
| return $array; | |
| } | |
| } | |
| $db = new Db(); | |
| $db->format($db->query("SELECT * FROM guest_book")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment