Very easy to use PDO MYSQL API. Just Include in PHP file and get it working.

Last update: Jun 14, 2022

CRUD-MYSQL-API

Very easy to use PDO MYSQL API. Just Include in PHP file and get it working.

INSTALATION

Step 1:

git clone https://github.com/arhex-labs/CRUD-MYSQL-API-PHP.git

Step 2:

Copy the files in core directory of project. Done.

USAGE

1. Establish Connection

Establish a connection between server and database.

Example:

$con = new DB('127.0.0.1', 'myDB', 'root', 'toor');

Syntax:

$con = new DB('DATABASE_HOST', 'DATABASE_NAME', 'DATABASE_USERNAME', 'DATABASE_PASSWORD');

2. Insert Row

Insert a row in database table.

Example:

$data = ['ARHEX', 'LABS', '[email protected]'];
$con->insert_row('users', $data); # List of all fields to insert.

Note: ID AUTOINCREMENT FIELD IS AUTOMATICALLY ADDED.

Syntax:

$ARRAY_OF_DATA = [FIELD_1, FIELD_2, ....];
$con->insert_row([TABLE_NAME], [ARRAY_OF_DATA]); # List of all fields to insert.

3. Delete Row

Delete a row in database table by using field name and key.

Example:

$con->delete_row('users', 'users_id', '3');

Syntax:

$con->delete_row([TABLE_NAME], [FIELD_NAME], [KEY]);

4. Update Row

Update a row in database table using key to select row and field name to update data.

Example:

$con->update_row('users', 'users_email', '[email protected]', 'users_id', '1');

Syntax:

$con->update_row([TABLE_NAME], [FIELD_NAME], [DATA], [KEY], [VALUE]);

5. Get Field Value

Return field value from selected database table using key to select row and field name to select field.

Example:

$con->get_field_value('users', 'users_id', '3', 'users_email');

Snytax:

$con->get_field_value([TABLE_NAME], [KEY], [VALUE], [FIELD_NAME]);

6. Get Last Id

Return the last row in database table sorted by primary integer keys.

Example:

$con->get_last_id('users', users_id);

Syntax:

$con->get_last_id([TABLE_NAME], [NAME_OF_PRIMARY_KEY_FIELD]);

7. Get Single Row

Return a single row using table name, key and value.

Exmaple:

$row = $con->get_row('users', 'users_id', '3');
$email = $row[0]['users_email'];

Syntax:

$con->get_row([TABLE_NAME], [Key], [VALUE]);

8. Get All Rows

Return all selected rows using table name, key and value.

Example:

$row = $con->get_row('users', 'users_id', '3');
$email_1 = $row[0]['users_email'];
$email_2 = $row[1]['users_email'];
$name_3 = $row[2]['users_email'];

Syntax:

$con->get_row([TABLE_NAME], [Key], [VALUE]);

9. Read Table

Return all selected table rows using only table name.

Example:

$con->read_table('posts');

Syntax:

$con->read_table([TABLE_NAME]);

Credits

Developer: Abdul Raheem (ARHEX)

GitHub

https://github.com/arhex-labs/CRUD-MYSQL-API-PHP
You might also like...

Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

Eloquent Filter Eloquent Filter adds custom filters to your Eloquent Models in Laravel. It's easy to use and fully dynamic. Table of Content Introduct

Aug 13, 2022

An easy-to-use Artisan command to create a new database schema.

Laravel Create DB This package adds an easy-to-use Artisan command to your application that allows you to create a new database schema. The package is

Jul 9, 2022

Symfony 5.2 + api platform project with ELK stack + elastic FileBeats for the log management. All running in 7 docker containers: nginx, php 8, mysql, elastic search, logstash, kibana, fileBeats.

Symfony with ELK and Elastic FileBeats Stack Prerequisites: Make sure that docker and docker-compose are installed in your machine and available for y

May 20, 2022

TO DO LIST WITH LOGIN AND SIGN UP and LOGOUT using PHP and MySQL please do edit the _dbconnect.php before viewing the website.

TO-DO-LIST-WITH-LOGIN-AND-SIGN-UP TO DO LIST WITH LOGIN AND SIGN UP and LOGOUT using PHP and MySQL please do edit the _dbconnect.php before viewing th

Sep 28, 2021

phpMyFAQ - Open Source FAQ web application for PHP and MySQL, PostgreSQL and other databases

phpMyFAQ 3.1 What is phpMyFAQ? phpMyFAQ is a multilingual, completely database-driven FAQ-system. It supports various databases to store all data, PHP

Jun 22, 2022

A simple and extensible fixture loader for PHP 7.3+, supporting SQLite and MySQL

Flowder Flowder is a (really) simple fixture loader for PHP 7.3+, supporting SQLite and MySQL. Using Flowder in PHP 7.2 or below? Try version 1 instea

Jan 17, 2021

Connect and work with MySQL/MariaDB database through MySQLi in PHP. This is an introductory project, If you need a simple and straightforward example that takes you straight to the point, you can check out these examples.

Connect and work with MySQL/MariaDB database through MySQLi in PHP. This is an introductory project, If you need a simple and straightforward example that takes you straight to the point, you can check out these examples.

First MySQLi PHP Connect and work with MySQL/MariaDB database through MySQLi in PHP. The above exercises are designed for students. This is an introdu

Feb 22, 2022

A simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure)

my little forum my little forum is a simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure).

Aug 3, 2022

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

Jan 7, 2022
Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Jul 14, 2022
Easy-to-use PDO wrapper for PHP projects.

EasyDB - Simple Database Abstraction Layer PDO lacks brevity and simplicity; EasyDB makes separating data from instructions easy (and aesthetically pl

Aug 4, 2022
Tiny php mysql lib (PDO-based) with handy fetch/update functionality, supports both SQL and parametric queries

Micro PHP mysql lib (~ 200 lines of code) with ultra powerful CRUD for faster than ever development: parametric fetch/insert/update/delete (based on a

Feb 22, 2022
Staggered import of large and very large MySQL Dumps even through the web servers with hard runtime limit and those in safe mode.

Staggered import of large and very large MySQL Dumps (like phpMyAdmin dumps) even through the web servers with hard runtime limit and those in safe mode. | Persian Translation Version

Jan 8, 2022
SQL database access through PDO.

Aura.Sql Provides an extension to the native PDO along with a profiler and connection locator. Because ExtendedPdo is an extension of the native PDO,

Jul 30, 2022
You can sync any number of PDO supported databases

Features: Can backup any number of databases. No need to introduce column name only table name The Last id based data backup Support 12 different data

Aug 27, 2021
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

Feb 14, 2022
Get MYSQL statement from query builder in laravel helper

Get MYSQL statement laravel This package allows to get mysql statement that query builder in laravel made it for debugging purposes. Basic usage Dump

Jul 15, 2022
A working Firebase http client
A working Firebase http client

PHP library access Firebase RESTful API Installation $ composer require jaredchu/jc-firebase-php Usage Generate a private key in JSON format. Check Fi

Jul 10, 2022
Small script for importing the KvK (Dutch Chamber of Commerce) Open Data Set (CSV file) to a MySQL database.
Small script for importing the KvK (Dutch Chamber of Commerce) Open Data Set (CSV file) to a MySQL database.

KvK-CSV-2-SQL Small script for importing the KvK (Dutch Chamber of Commerce) Open Data Set (CSV file) to a MySQL database. Table of content KvK-CSV-2-

Aug 5, 2022