About SimpleDB
Hi dear Envato Community,
SimpleDB library aims to help you get rid of writing sql
queries and switching between your code editor and database management tool.
SimpleDb is a smart four-in-one library which assists you throught your project
development proccess in database layer. In simple words you can manage the process of;
- Define New Database
- Create MySql Connections using PHP’s PDO library
- Run your queries with easily
- Create Database migrations just writing a php variable
- Run CRUD commands with just a single line.
Available Classes
Here is a short description about classes available on SimpleDB to help you to understand what class is for what.
- ConnectionString class; This class aims to help you creating a valid connection string to use in SimpleDb database connections.
- MySqlConnection class; This class is used to manage your database connections. Initialize a database connection and test if you are connected or not.
- Database class; This class used in migrations. Define a database to run a migration command.
- Migration class; This class is used to run a database migration (up/down) commands with the help of the Database class.
- Database, Table, Field classes; You can use this 3 classes to create a database. Examples are available in this documentation file
- SimpleCrud class; Run Create, Read, Update, Delete commands with a single line and get rid of complex queries.
- SimpleDB class; This class is used to load the SimpleDB library hierarchically to your code base.
Documentation
SimpleDb has fully documented code and easy to read user manual. We strongly recommend downloading the user manual before buying our product to decide if this product is suitable for you.
Sample Code Snippets
Create a database connection and run a simple query;
require 'simpledb.php'; SimpleDB()::ImportAll(); $connection = new MySqlConnection(new ConnectionString("localhost", "username", "password", "db_name")); $cmd = new MySqlCommand("select * from users", $connection->getConnection()); $data = $cmd->FetchAll();
Use CRUD Library to get the same result with code snippet above;
require 'simpledb.php'; SimpleDB()::ImportAll(); $connection = new MySqlConnection(new ConnectionString("localhost", "username", "password", "db_name")); $crud = new SimpleCrud(); $crud->setConnection($connection); $crud->setDatabase(); $data = $crud->Read("users", "*");
Run a query with parameters
require 'simpledb.php'; SimpleDB()::ImportAll(); $connection = new MySqlConnection(new ConnectionString("localhost", "username", "password", "db_name")); $cmd = new MySqlCommand("insert into table(id, username) values(:id, :username);", $connection->getConnection()); $cmd->bindParameter(":id", $_POST["id"]); $cmd->bindParameter(":id", $_POST["username"]); $cmd->Execute();
Database Migration
For creating migration with SimpleDB there is no need for third party tool and running a command line prompt every time you change your database schema. When production mode is disabled from the migration class every time the class checks for remote and current database version, if there is a new database version its created automatically when the page loaded(Index page is a good place to control your migrations).
Here is a flowchart which shows how SimpleDB migration works and a simple code snippet for creating a database called ‘simleblog’ and a table called ‘users’.
<?php require 'includes'.DIRECTORY_SEPARATOR.'simpledb.php'; SimpleDB::ImportAll(); $connect = new MySqlConnection(new ConnectionString("localhost", "userx", "pass_x")); $db = new Database("simpleblog"); $db->setVersion(1) ->setTables( new Table("users", new Field("userid", "int", "PRYMARY KEY AUTO_INCREMENT"), new Field("username", "varchar(20)", "unique"), new Field("password", "varchar(200)", "not null") , new Table("posts", new Field("data1", "varchar(200)"), new Field("data2", "varchar(200)") ) ) ) ->Create(); $migration = new Migration(); $migration->setConnection($connect) ->setDatabase($db) ->setProduction(false) ->Up();
Kindly Note: We update new contents like WordPress Themes, Plugins, PHP Scripts everyday. But remember that you should never use this items in a commercial website. All the contents posted here for development & testing purpose only. We’re not responsible for any damage, use at your own RISK! We highly recommend to buy SimpleDB – All In One MySql Database Library (Connections, Commands, Migrations, Crud Library) from the The Developer ( ioscript ) website. Thank you.
Download = SimpleDB – All In One MySql Database Library (Connections, Commands, Migrations, Crud Library)-[Updated].zip