Am I on the right track? PHP/MySQL I have the following table called info:

info_name   |   info_value

name        |   Susan

desc        |   Human


I'm trying to print Susan without knowing that the value is Susan.

The following code works, but I want to know if what I wrote is correct.

I'm open to any improvements.

Config Class:

class Config {

    private $hostname = 'localhost';
    private $username = 'blah';
    private $password = 'blah';
    private $database = 'blah';

    public function __construct()
    {
        $this-&gt;connection = new mysqli($this-&gt;hostname,$this-&gt;username,$this-&gt;password,$this-&gt;database);

        if($this-&gt;connection-&gt;connect_errno) 
        {
            die('Error: ' . $this-&gt;database-&gt;error);
        }
    }

    public function query($query)
    {
        return $this-&gt;connection-&gt;query($query);
    }

    public function __destruct()
    {
        $this-&gt;connection-&gt;close(); 
    }

}


Name Class:

class Name {

    protected $name;

    public function __construct()
    {
        $this-&gt;db = new Config;

        $r = $this-&gt;db-&gt;query('SELECT info_value FROM info WHERE info_name="name"');

        while($row = $r-&gt;fetch_row())
        {
            $this-&gt;name = $row['0'];
        }

    }

    public function getName()
    {
        return $this-&gt;name;
    }

}


Print Results:

&lt;?php $show_name = new Name(); echo $show_name-&gt;getName(); ?&gt;


Thanks for any help!
Your config and name classes are good starts. Here are a few humble suggestions:


I highly suggest steering clear of what is called the entity-attribute-value pattern when structuring your MySQL tables. Here is an article that discusses ways of refactoring. Also, if you are interested in learning more about mysql (and sql in general) I highly recommend the book SQL Antipatterns by Bill Karwin.
In the future, if your projects grow and you want a more robust system, you may want to look into a few concepts such as dependency injection, which will help if and (hopefully) when you ever start unit testing with software like PHPUnit.


Hope this helps!