Skip to content

Instantly share code, notes, and snippets.

@VictorFursa
Last active January 12, 2016 12:19
Show Gist options
  • Select an option

  • Save VictorFursa/6977ef6e90d2903e4006 to your computer and use it in GitHub Desktop.

Select an option

Save VictorFursa/6977ef6e90d2903e4006 to your computer and use it in GitHub Desktop.
<?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