Return to Snippet

Revision: 24063
at February 19, 2010 17:30 by alvincrespo


Initial Code
<?php

/*
 * Author: Alvin Crespo
 * Date: 2/19/2010
 * 
 * Database Manager
 *
 * */

class dbmanager{
	
	private $db_link;
	private $hostname = 'localhost';
	private $username = 'username';
	private $password = 'password';
	private $dbname;
	
	function __construct($dbname){
		
		$this->dbname = $dbname;
		$this->db_connect();
		
	}
	
	function db_connect(){
		
		$this->db_link = new mysqli($this->hostname, $this->username, $this->password, $this->dbname);
		
	}
		
	function db_query($query){
		
		$result = $this->db_link->query($query);
				
		while($row = $result->fetch_array(MYSQLI_ASSOC)){
			$rows[] = $row;
		}
		
		return $rows;
		
	}
	
}

Initial URL

                                

Initial Description
Just a beginning, hoping to refine this ASAP.

Initial Title
PHP Database Connection Class

Initial Tags
database, class, php

Initial Language
PHP