Griffith Designs

PHP & MySQL Database Class

by webmasterjunkie on Nov.03, 2010, under MySQL, PHP, Programming

Here is a little class for your PHP and MySQL applications:

PHP MySQL Database Class (97)

You would of course have to extend it to match your needs, but it’s a great start to solve those redundant coding problems.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
include_once("db.inc.php");
 
class db {
 
public function db_connect () {
    global $config;
    if ($this->con == false) {
        $db = @mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"]);
        if ($db) {
            $dbe = @mysql_select_db ($config["dbname"], $db);
                if ($dbe) {
                    $this->con = true;
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
    } else {
        return false;
    }
}
 
}
 
// More in the ZIP file attached to this thread.
:, ,

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Connect