A simple library for managing database connections, results pagination and building queries in PHP

Overview

PHP lions-software-database-manager

This is a simple library for managing database connections, results pagination and building queries in PHP.

Esta é uma biblioteca simples para gerenciar conexões de banco de dados, paginação de resultados e construção de consultas em PHP.

Installation

Use Composer to install lions-software-database-manager in your project

Use o Composer para instalar o lions-software-database-manager em seu projeto:

composer require lions-software/lions-software-database-manager

Usage

To use this library just follow the examples below:

Para utilizar esta biblioteca basta seguir os exemplos abaixo:

Database



require 'vendor/autoload.php';

use LionsSoftware\DatabaseManager\Database;

//DATABASE CREDENTIALS
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = 'pass';
$dbName = 'database';
$dbPort = 3306;
$dbDriver = 'mysql';

//CONFIG DATABASE CLASS
Database::config($dbHost,$dbUser,$dbPass,$dbName, $dbPort, $dbDriver);

//CONNECTION INSTANCE
$objDatabase = Database::Connection();

Pagination



require 'vendor/autoload.php';

use LionsSoftware\DatabaseManager\Database;
use LionsSoftware\DatabaseManager\Pagination;

//DATABASE CREDENTIALS
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = 'pass';
$dbName = 'database';
$dbPort = 3306;
$dbDriver = 'mysql';

//CONFIG DATABASE CLASS
Database::config($dbHost,$dbUser,$dbPass,$dbName, $dbPort, $dbDriver);

//CONNECTION INSTANCE
$objDatabase = Database::Connection();

//COUNT TOTAL RESULTS
$totalResults = $objDatabase->select('id > 10',null,null,'COUNT(*) as total')->fetchObject()->total;

//CURRENT PAGE
$currentPage  = $_GET['page'] ?? 1;
$itemsPerPage = 10;

//PAGINATION
$objPagination = new Pagination($totalResults,$currentPage,$itemsPerPage);

//SELECT (return a PDOStatement object)
$results = $objDatabase->select('id > 10',null,$objPagination->getLimit());

//PAGES (array)
$pages = $objPagination->getPages();

Requirements

This library needs PHP 8.0 or greater.

You might also like...
Just another PDO database library

PDO Just another PDO database library Installation Use Composer $ composer require faapz/pdo Usage Examples selecting, inserting, updating and deletin

Tablavel - A simple Database Client for Laravel

Tablavel - A simple Database Client for Laravel Table of Contents About Getting Started Usage Contributing About This solves a simple problem. Know th

Orm is a simple database abstraction layer that supports postgresql.

Orm What is it Orm is a simple database abstraction layer that supports postgresql. Welcome to join us or star us for encouragement. Requires php 8.1

Clean up your Magento database by removing orphaned, unused and wrongly added attribute, attribute values and settings (for M2).

Magento 2 EAV Cleaner Console Command Purpose of this project is to check for different flaws that can occur due to EAV and provide cleanup functions.

This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud

Database Backup Manager This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FT

ORM layer that creates models, config and database on the fly

RedBeanPHP 5 RedBeanPHP is an easy to use ORM tool for PHP. Automatically creates tables and columns as you go No configuration, just fire and forget

A Redis based, fully automated and scalable database cache layer for Laravel
A Redis based, fully automated and scalable database cache layer for Laravel

Lada Cache A Redis based, fully automated and scalable database cache layer for Laravel Contributors wanted! Have a look at the open issues and send m

The query filter bundle allows you to filter data from QueryBuilder and the Database
The query filter bundle allows you to filter data from QueryBuilder and the Database

The query filter bundle allows you to filter data from QueryBuilder and the Database. you can filter multiple columns at the same time and also you can filter relation fields with two-level deep and without any join in your query builder.

A link database for discovering cool and interesting websites

Yesterlinks Yesterlinks is a database of links to unique or interesting websites. This is a project, in its infancy, designed to be a directory of lin

Releases(v0.1.2)
Owner
Lions Software
Lions Software é a solução IDEAL para pequenas empresas, prestadores de serviço e profissionais liberais/autônomos.
Lions Software
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

Mr Crypster 18 Dec 10, 2022
Easily exclude model entities from eloquent queries

Laravel Excludable Easily exclude model entities from eloquent queries. This package allows you to define a subset of model entities who should be exc

H-FARM 49 Jan 4, 2023
A Symfony application for managing and automating regular backups of MySQL databases.

DbSaver DbSaver is an application written by Bastien LOUGHIN allowing you to make automatic daily backups (and manual backups) for your MySQL database

Bastien 35 Nov 11, 2022
SleekwareDB is a NoSQL database storage service. A database storage service that can be used for various platforms and is easy to integrate.

SleekwareDB is a NoSQL database storage service. A database storage service that can be used for various platforms and is easy to integrate. NoSQL API

SleekwareDB 12 Dec 11, 2022
A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL.

grifart/tables A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL. This library is develope

GRIFART 5 Nov 11, 2022
Pure PHP NoSQL database with no dependency. Flat file, JSON based document database.

Please give it a Star if you like the project ?? ❤️ SleekDB - A NoSQL Database made using PHP Full documentation: https://sleekdb.github.io/ SleekDB i

Kazi Mehedi Hasan 745 Jan 7, 2023
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

Max Base 4 Feb 22, 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.

Mark Armendariz 0 Jan 7, 2022
A complete, simple and powerful database framework written in PHP

BaseSQL BaseSQL is a complete database framework written in PHP. It was built to accelerate projects development by handle database connections and qu

Willian Pinheiro 2 Sep 21, 2021
A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.

Eloquence Eloquence is a package to extend Laravel's base Eloquent models and functionality. It provides a number of utilities and classes to work wit

Kirk Bushell 470 Dec 8, 2022