11-28-2008, 01:46 AM
|
#13 (permalink)
|
|
The Addict
Join Date: Apr 2008
Posts: 200
Thanks: 18
|
Yes, i have done updating my codes, and i have choose to use an interface for my class.
db.php - interface
PHP Code:
<?php
interface db { public function connect(); public function query($query); public function close(); }
?>
mysql.class.php - mysql classes/functions
PHP Code:
<?php
require "includes/db.php";
class dbmysql implements db { private $link; public function connect($dbhost='', $dbuser='', $dbpass='') { $this->link = mysql_connect($dbhost, $dbuser, $dbpass); } public function query($query) { return mysql_query($query, $this->link); } public function close() { return mysql_close($this->link); } }
?>
index.php
PHP Code:
<?php
include('includes/mysql.class.php'); include('includes/dbconfig.php');
$at_Mdb = new dbmysql(); $at_Mdb->connect($s_host, $s_user, $s_pass); $sql = "create database $s_dbname"; $query = $at_Mdb->query($sql); $at_Mdb->close();
?>
dbconfig.php
PHP Code:
<?php
$s_host = 'localhost'; $s_user = 'root'; $s_pass = ''; $s_dbname = 'usys';
?>
i got these running and fully working, and so far i think im good to start it now :) Thanks for all the comments and suggestions. You help me a lot understand more about these things.
Any more comments and suggestions are welcome to help me visualize and improvise which is really better for usability of codes :)
Regards,
t3st
|
|
|
|