View Single Post
Old 11-27-2008, 11:24 PM   #7 (permalink)
zxt3st
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default

So far, this are still the things i have done. My codes are below, and any critiques about it are very much welcome for me to improve.

sample_db.php
PHP Code:
<?php

class DBMysql
{
    var 
$query;
    
    public function 
__construct($db_host$db_user$db_pass)
    {
        
$this->dbhost $db_host;
        
$this->dbuser $db_user;
        
$this->dbpass $db_pass;
    }
    
    public function 
connect()
    {
        
$dblink = @mysql_connect($this->dbhost$this->dbuser$this->dbpass);
        if (
$dblink)
        {
            echo 
"success";
        }
        else
        {
            die(
'Mysql Error!.');
        }
    }
    
    public function 
do_query($dbquery)
    {
        
$result = @mysql_query($this->query);
        if (
$result)
        {
            echo 
"Successfull!";
        }
        else
        {
            throw new 
exception('Error executing query!.');
        }
    }
    
    public function 
disconnect()
    {
        
//mysql close here
    
}
}

?>
index.php
PHP Code:
<?php
error_reporting
(E_ALL);
include(
'sample_db.php');
include(
'dbconfig.php');

$connection = new DBMysql($at_Mhost$at_Muser$at_Mpass);
$connection->connect();

$sql "Create table aldin";

?>
dbconfig.php
PHP Code:
<?php

$at_Mhost 
'localhost';
$at_Muser 'root';
$at_Mpass '';

?>
I got problem on the query part, though im reading more on stuff, implementing a mysql class.

Feedback?

Thnx.
__________________
Serenity Project - 5% (Layout) - Ongoing....
Project Serenity Free Life!....
zxt3st is offline  
Reply With Quote