PHP code example of lions-software / lions-software-database-manager
1. Go to this page and download the library: Download lions-software/lions-software-database-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lions-software / lions-software-database-manager example snippets
composer
nsSoftware\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();
nsSoftware\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();