Expand|Select|Wrap|Line Numbers
- <?PHP
- //THIS IS MY DB CLASS CONNECTION
- class db
- {
- private $hostname;
- private $username;
- private $password;
- private $database;
- private $connect;
- private $select_db;
- public $dbSql;
- public function db()
- {
- $this->hostname = "localhost";
- $this->username = "root";
- $this->password = "";
- $this->database = "mydb";
- }
- public function open_connection()
- {
- try
- {
- $this->connect = mysql_connect($this->hostname,$this->username,$this->password);
- $this->select_db = mysql_select_db($this->database);
- }
- catch(exception $e)
- {
- return $e;
- }
- }
- public function close_connection()
- {
- try
- {
- mysql_close($this->connect);
- }
- catch(exception $e)
- {
- return $e;
- }
- }
- }
- ?>
- <?php
- //Class to use the db class....
- include('db.php');
- class usr{
- private $mydb;
- $mydb = new db;//::open_connection();
- public function users_query()
- {
- try
- {
- //$this->$mydb->open_connection();
- $mydb->dbSql = mysql_query("SELECT * FROM users");
- }
- catch(exception $e)
- {
- return $e;
- }
- $mydb->close_connection();
- return $mydb->dbSql;
- }
- }
- ?>
- <?php
- //AND MY OTHER CODES TO DISPLAY THE RECORDS...
- //DISPLAY USERS***************************
- include('..//controller/getrecord.php');
- $grec=new grecord();
- $grec->display_users();
- //****************************************
- ?>