[ad_1]
To get this product on 50 % contact me on this link
About SimpleDB
Hi pricey Envato Community,
SimpleDB library goals that will help you eliminate writing sql
queries and switching between your code editor and database administration instrument.
SimpleDb is a great 4-in-one library which assists you throught your venture
improvement proccess in database layer. In easy phrases you’ll be able to handle the method of;
- Define New Database
- Create MySql Connections utilizing PHP’s PDO library
- Run your queries with simply
- Create Database migrations simply writing a php variable
- Run CRUD instructions with only a single line.
Available Classes
Here is a brief description about lessons obtainable on SimpleDB that will help you to know what class is for what.
- ConnectionString class; This class goals that will help you creating a sound connection string to make use of in SimpleDb database connections.
- MySqlConnection class; This class is used to handle your database connections. Initialize a database connection and check in case you are related or not.
- Database class; This class utilized in migrations. Define a database to run a migration command.
- Migration class; This class is used to run a database migration (up/down) instructions with the assistance of the Database class.
- Database, Table, Field lessons; You can use this three lessons to create a database. Examples can be found on this documentation file
- EasyCrud class; Run Create, Read, Update, Delete instructions with a single line and eliminate complicated queries.
- SimpleDB class; This class is used to load the SimpleDB library hierarchically to your code base.
Documentation
SimpleDb has totally documented code and straightforward to learn person handbook. We strongly suggest downloading the person handbook earlier than shopping for our product to determine if this product is appropriate for you.
Sample Code Snippets
Create a database connection and run a easy question;
require 'simpledb.php'; SimpleDB()::ImportAll(); $connection = new MySqlConnection(new ConnectionString("localhost", "username", "password", "db_name")); $cmd = new MySqlCommand("select * from users", $connection->getConnection()); $knowledge = $cmd->FetchAll();
Use CRUD Library to get the identical outcome with code snippet above;
require 'simpledb.php'; SimpleDB()::ImportAll(); $connection = new MySqlConnection(new ConnectionString("localhost", "username", "password", "db_name")); $crud = new EasyCrud(); $crud->setConnection($connection); $crud->setDatabase(); $knowledge = $crud->Read("users", "*");
Run a question 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 isn’t any want for third get together instrument and working a command line immediate each time you alter your database schema. When manufacturing mode is disabled from the migration class each time the category checks for distant and present database model, if there’s a new database model its created routinely when the web page loaded(Index web page is an efficient place to regulate your migrations).
Here is a flowchart which exhibits how SimpleDB migration works and a easy code snippet for making a database referred to as ‘simleblog’ and a desk referred to as ‘customers’.
<?php require 'contains'.DIRECTORY_SEPARATOR.'simpledb.php'; SimpleDB::ImportAll(); $join = 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($join) ->setDatabase($db) ->setProduction(false) ->Up();
[ad_2]
To get this product on 50 % contact me on this link