Skip to content

Database class uses OOP and PDO for secure transactions. Although this class does use PDO, please validate and sanitize your data before attempting to query the database. For more information, please read README.md

oestrada1001/pdo-oop-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

PDO OOP Database Connection

Attention

The Database class allows you to make database changes using PDO.
By design, the Database Class does not do any validation or sanitation.

For debugging purposes, Errors are set to display.
For production, please remove attributes: 'PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION'.

Credentials

The credentials are passed when when the Database class is instantiated. The credentials must comply with the following format AND INDEXES:

$_CREDENTIALS = array( 'driver' => 'driver_type', 'host' => 'host_name', 'database' => 'db_name', 'username' => 'username', 'password' => 'password' );

Insert Queries

Insert queries may have unlimited number of columns and their respected values as long as $dataset complies with the following format:

$array_name = [ 'column_name0' => 'column_value', 'column_name1' => 'column_value', ];

Select Queries

Select queries may have unlimited number of where clauses as long as the $conditionals complies with the following format:

$array_name = [ 'Clause' => [ 'column_name', '=', 'haystack_value'], 'And' => [ 'column_name', '>', 'haystack_value'] ];

If you need multiple 'And' or 'Or' use different letter cases.
I.E. AND, and, And, aND, anD, etc.

Additional Notes:


Following TTD and Agile Methodologies, I will be updating this class with more functionality as needed. This class follows the Single Responsibility Principle and it's only dependent on the database credentials.

About

Database class uses OOP and PDO for secure transactions. Although this class does use PDO, please validate and sanitize your data before attempting to query the database. For more information, please read README.md

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages