1. Go to this page and download the library: Download victormmeloc/datalayer 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/ */
victormmeloc / datalayer example snippets
// INSERE O AUTOLOAD
ayer;
// DEFINE A TABELA
Datalayer::setTable('users');
//DEFINE AS CONFIGURAÇÕES DO BANCO DE DADOS
Datalayer::config(
'localhost',
'datalayer',
'root',
'pass',
'3306'
);
new Datalayer;
Datalayer::pagination($page,$quantity,$filter,$columns);
// RETORNO
$arr = [
'previus' => página anterior, caso não tenha retornará null,
'next' => próxima página, caso não tenha retornará null,
'current' => página atual,
'quantityRows' => quantidade de linhas gerais da consulta,
'quantityPages' => quantidade de páginas,
'start' => linha inicial,
'end' => linha final,
'data' => objeto com os dados,
];
// PARAMETROS
/**
* PAGE
* a página que deseja fazer a pesquisa
* @param int $page
* valor default é '1'
*/
$page = 1;
/**
* QUANTITY
* a quantidade de retornos por página
* @param int $quantity
* valor default é '50'
*/
$quantity = 50;
/**
* FILTER
* os filtros da consulta. Esse filtro representa a cláusula WHERE da consultar
* @param array $filter
* valor default é '[]'
*/
$filter = [
'name' => [
'operator' => '=',
'value' => 'Victor'
],
'email' => [
'operator' => 'LIKE',
'value' => 'M%'
]
];
/**
* COLUMNS (opcional)
* as colunas que deseja retornar
* @param string $columns
* valor default é '*'
*/
$columns = 'name,email';