PDO Helper Class (Database Abstractions)

Check The Full Documentation to See All The Examples.

othPDo is a php class that contains methods will provide an easier and safer way to connect to the database. Getting your query results will be in one line only, and with a lot of agile options that will make your query even more easier than any other method.

Quick Examples:

This will get all the rows from table users

$users = $othPDO->getALL("users");

This will get all the rows from table users and order it by email

$users = $othPDO->getALL("users","email");

This will check the username and password in one line, changing the false to true will return boolean

// Get all for username = othman and password = 1111
$array = array(
    "username" => "othman",
    "password" => "1111" 
);
$users = $othPDO->getWithCondition("*","users",$array,"AND",false);

Search:

This will search for “PHP” in column quote in table search

$result = $othPDO->search("search","quote","PHP");

INSERT:

If you are going to pass all the fields in the database, then you can use this.

$arr = array("NULL","newUsername","newPassword","newEmail");

$othPDO->insert("users",$array);

if you are going to pass some of the fields in the database, then you can use this.


$array = array(
    "id"       => "NULL", // if your id is an auto increment field 
    "username" => "myUsername",
    "password" => "myPassword" 
);
$othPDO->insert("users",$array);

Execute Your Own SQL Query

$myResult = $othPDO->execute("SELECT * FROM users");

// with vars
$myResult = $othPDO->execute("SELECT * FROM users where i = ? AND o = ?",$i,$o);

Check The Full Documentation to See All The Examples.

Download PDO Helper Class (Database Abstractions)

Leave a Reply

Your email address will not be published. Required fields are marked *