Skip to content

This is a really neat Database class that allows you to easily get started with PDO statements and MySQL/PHP

License

Notifications You must be signed in to change notification settings

yazinsai/php-pdo-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

PHP PDO MySQL Wrapper

This PHP Class makes it ridiculously easy to use Prepared Statements in your MySQL projects.

How does it work?

Just start by including the class in your script:

include Database.php

Now use it like so:

$DB = new Database();
$DB->query("SELECT * FROM `mytable` WHERE `myfield`=:myvalue",
   array(":myvalue" => $myvalue));
$results = $DB->fetchAll();

You now have all of the results in your $results variable! You can iterate through the results like so:

foreach($results as $result) {
   // $result contains an associative array with all the fields
   echo "Result: " . $result['myfield']
}

Setup

Just edit the $CONFIG variable in the Database.php file with the connection details:

$CONFIG = array(
  "database" => array(
    "host"     => 'localhost',
    "database" => 'database',
    "username" => 'username',
    "password" => 'password'
    )
  );

Why use this class?

Coz it makes yo' life a whole lot easier. And prepared statements are about 1,000,000 times more secure than plain SQL.

About

This is a really neat Database class that allows you to easily get started with PDO statements and MySQL/PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages