php oop and mysql

Posted by gloris on Stack Overflow See other posts from Stack Overflow or by gloris
Published on 2010-05-27T18:40:58Z Indexed on 2010/05/28 1:41 UTC
Read the original article Hit count: 226

Filed under:

I need to get data, to check and send to db. Programming with PHP OOP.

Could you tell me if my class structure is good and how dislpay all data?. Thanks

<?php
class Database{

    private $DBhost = 'localhost';
    private $DBuser = 'root';
    private $DBpass = 'root';
    private $DBname = 'blog';

    public function connect(){
        //Connect to mysql db
    }

    public function select($rows){
        //select data from db
    }

    public function insert($rows){
        //Insert data to db
    }

    public function delete($rows){
        //Delete data from db
    }
}

class CheckData{

    public $number1;
    public $number2;

    public function __construct(){
        $this->number1 = $_POST['number1'];
        $this->number2 = $_POST['number2'];
    }

    function ISempty(){
        if(!empty($this->$number1)){
            echo "Not Empty";

            $data = new Database();
            $data->insert($this->$number1);
        }
        else{
            echo "Empty1";
        }

        if(!empty($this->$number2)){
            echo "Not Empty";

            $data = new Database();
            $data->insert($this->$number2);
        }
        else{
            echo "Empty2";
        }       
    }
}

class DisplayData{

    //How print all data?
    function DisplayNumber(){
        $data = new Database();
        $data->select();
    }   
}

$check = new CheckData();
$check->ISempty();

$display = new DisplayData()
$display->DisplayNumber();
?>

© Stack Overflow or respective owner

Related posts about php