Download the PHP package entomb/obj_mysql without Composer
On this page you can find all versions of the php package entomb/obj_mysql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download entomb/obj_mysql
More information about entomb/obj_mysql
Files in entomb/obj_mysql
Package obj_mysql
Short Description MySQL abstraction layer
License GPL 3.0
Homepage https://github.com/entomb/OBJ-MySQL
Informations about the package obj_mysql
OBJ-MySQL
OBJ MySQL is a simple MySQL Abstraction Layer for PHP>5.2 that provides a simple and secure interaction with your database using mysqli_* functions at its core.
OBJ-MySQL is perfect for small scale applications such as cron jobs, facebook canvas campaigns or micro frameworks or sites.
This project is under construction, any feedback would be appreciated
Author: Jonathan Tavares
checkout the changelog for info on the latest changes
Get OBJ_MySQL
You can download it from here, or require it using composer.
Or you can require it by cloning this repo
If you are already using GIT on you project you can add it as a submodule
Starting the driver
To start the db driver you must include the main class file and pass the '$config' array described bellow. you can have multiple instances of the Class each one with its own $config (one for Reads and one for Writes for example).
Using OBJ_MySQL
there are numerous ways of using this library, here are some examples of the most common methods
Selecting and retrieving data from a table
Inserting data on a table
To manipulate tables you have the most important methods wrapped, they all work the same way: parsing arrays of key/value pairs and forming a safe query
the methods are:
All methods will return the resulting mysqli_insert_id()
or true/false depending on context.
The correct approach if to always check if they executed as success is always returned
note: All parameter values are sanitized before execution, you don't have to escape values beforehand.
binding parameters on queries
Binding parameters is a good way of preventing mysql injections as the parameters are sanitized before execution.
Using the OBJ_mysql_result Class
After executing a SELECT
query you receive a OBJ_mysql_result
object that will help you manipulate the resultant data.
There are different ways of accessing this data, check the examples bellow:
Fetching all data
Fetching all data works as Object
or Array
the fetchAll()
method will return the default based on the $_default_result_type
config.
Other methods are:
Aliases
Iterations
To iterate a resultset, you can use any fetch() method listed above
Logging and Errors
Showing the query log. the log comes with the SQL executed, the execution time and the result row count (if any)
To debug mysql errors:
Use $db->errors()
to fetch all errors (returns false if no errors) or $db->lastError()
for information on the last error.