Quantcast
Channel: CoryBorrow.Blog();
Viewing all articles
Browse latest Browse all 8

PHP Stuff : My database class

$
0
0

PHP Stuff : My database class.

When developing websites I usually have a database class of my own that I use,
I have a new one that I am starting to create now and it is quite simple to use.

Such as a simple query with a single where statement.


include "Database.php";
$db = new Database("localhost", "user", "pass", "dbname");
$db->connect();

$db->where("age", 18, WhereOperator::$MoreThan)
	->where("age", 25, WhereOperator::$LessThan)
	->orWhere("age", 45, WhereOperator::$Equal)
	->select("persons");
	
$row = $db->fetch();

Pretty simple huh? I like how it works.
As for the WhereOperator there are a few operators you can use as you
can see in the WhereOperator class.


class WhereOperator
{
    public static $Equal = 0;
    public static $Like = 1;
    public static $LessThan = 2;
    public static $MoreThan = 3;
    public static $LessThanOrEqual = 4;
    public static $MoreThanOrEqual = 5;
    public static $NotEqual = 6;
    public static $In = 7;
    public static $NotIn = 8;
    public static $Contains = 9;
    public static $NotContains = 10;
    public static $Between = 11;
    public static $NotBewteen = 12;
    public static $BeginsWith = 13;
    public static $NotBeginsWith = 14;
    public static $Contains = 15;
    public static $NotContains = 16;
    public static $NotLike = 17;
    public static $IsNull = 18;
    public static $IsNotNull = 19;
}

I’ll have this class posted up later after I get everything finished up, it
is going to be part of a small framework I am working on for myself.

The framework is really just a little personal project something to have
fun with, but it may get used in a couple of sites I’ll post the code
of that on sourceforge or github or something of the like, until then…
high ho silver away…


Viewing all articles
Browse latest Browse all 8

Trending Articles