A lightweight PHP library to perform SQL operations easily and securely
Features
Feature | Description |
---|---|
Negligible size | EasySQL is less than 1KB (minified and gzipped). |
Fast and convenient | Write only one line of code to perform simple or complex CRUD database operations. |
Avoid SQL Injection | EasySQL uses prepared statements and escapes user input. |
Error logging | Track script errors easily. |
Extra functionality | Error minification, custom error codes, enable/disable backtrace |
Error Debugging | Easily debug your project by viewing the backtrace output in error exception object. |
Error Handling | Handle errors gracefully in your project by taking advantage of the exception class. |
Plug & Play | EasySQL is pretty simple to use; just include it in your script and you're good to go! |
Wide Support | EasySQL supports all browsers and servers which can process PHP. |
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
git clone http://github.com/tawn33y/easysql
Prerequisites
You need the following to install and use the project:
- Web server - tool for running the PHP scripts, for example, Apache Web Server
- Database server - RDBMS database program, MySQL
- Web browser - tool to preview the result, for example, Google Chrome or Mozilla Firefox
- Text Editor - tool for editing your code, for example, Atom Text Editor, Sublime Text Editor or Notepad++
NOTE: This document does not contain steps on how to setup or configure the above tools; it is assumed that you're already familiar with this as well as the process of creating a dummy site and deploying it on a local (or online) server.
Installing
To use EasySQL, add the following at the beginning of your PHP code in your working script:
<?php
require_once("easysql.min.php");
?>
Running the tests
To run tests, visit the online demo or see the DEMO/README.md file for notes on how to test locally.
Deployment
To deploy this project on a live system, copy the distribution folder to your working environment:
git clone http://github.com/tawn33y/easysql/dist
cp dist /your/path
Next, provide valid database credentials in the credentials file as follows:
{
"database_type" : "",
"host_name" : "",
"host_username" : "",
"host_password" : "",
"database" : ""
}
Finally, include EasySQL in your working scripts, and configure it:
<?php
require_once("dist/easysql.min.php");
// create a new instance
$conn = new easysql();
// provide credentials
$conn->set_credentials_via_json_file("dist/credentials.json");
// (optional) enable error logging
$conn->set_logs_file_path("dist/logs.json");
$conn->set_logs_minify(true);
// your code follows here
// [...]
// destroy instance
$conn->__destruct();
unset($conn);
?>
Usage
For guidelines on how to use EasySQL, see the USAGE.md file or visit the project site.
Built With
Documentation
EasySQL uses an object-oriented approach highly facilitated by mixed inheritance, a combination of single and multilevel inheritance. For the classes' UML and relationship diagrams, see the UML.jpg file for more details. A full list of the classes is available in the UML.md file, and the unminified source code contains a description of the entire codebase.
Contributing
EasySQL is an open source software project and we encourage developers to contribute patches and code for us to include in the main package of EasySQL. All contributions will be fully credited - see the Contributing.md file for details on our code of conduct, and the process for submitting pull requests.
Versioning
This project uses semver for versioning. Current version: v1.0.0
Authors & Contributors
This version is mantained by K Tony. Many thanks to Smodav for introducing the concept of refactoring EasySQL via an Object Oriented approach in the previous version.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.