Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MySQL {
- /* Main Config */
- private $host = "localhost";
- private $user = "reeciebo_clients";
- private $password = "ilove2sk8";
- private $db_siteroot = "reeciebo_siteroot";
- private $db_clients = "reeciebo_clients";
- //// END
- /* Variables */
- private $db; private $table; private $fields;
- private $sql; private $query;
- private $arr;
- //// END
- public function __construct() {
- mysql_connect($this->host, $this->user, $this->path) or die(mysql_error()) ; //on Instantiation - A new connection will be created
- }
- /* Methods */
- public function getFields($db, $table, $fields) {
- if (isset($db, $table, $fields)) {
- mysql_select_db($this->db) or die(mysql_error());
- $sql = "SELECT " . $this->fields . " FROM `" . $this->table . "`";
- $query = mysql_query($sql) or die(mysql_error());
- if (mysql_num_rows($query) == 0) {
- return false;
- exit;
- }
- $this->fields = explode(",", $this->fields);
- while ($row = mysql_fetch_assoc($query)) {
- foreach ($this->fields as $val) {
- $arr['$val'] = $row['$val'];
- }
- }
- return $arr;
- }
- return false;
- }
- //// END
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement