1. Go to this page and download the library: Download mviniis/connection-database 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/ */
mviniis / connection-database example snippets
use \Mviniis\ConnectionDatabase\DTO\DTO;
class ProdutoDTO extends DTO {
protected $id;
protected $nome;
protected $preco;
protected $sku;
public function getParametrosClasse(): array {
return ['id', 'nome', 'preco', 'sku'];
}
public function getParametrosTabela(): array {
return ['id', 'nome', 'preco', 'sku'];
}
}
use \Mviniis\ConnectionDatabase\DB\DBExecute;
class Produto extends DBExecute {
protected string $table = 'produto';
protected string $modelData = ProdutoDTO::class;
}
$obProduto = new Produto;
use Mviniis\ConnectionDatabase\SQL\Parts\SQLWhere;
use Mviniis\ConnectionDatabase\SQL\Parts\SQLWhereGroup;
$condicoes = new SQLWhereGroup('AND', [
new SQLWhere('id', '=', 1)
]);
$obProduto->select($condicoes);
$obProduto->fetchObject()->nome;
foreach($obProduto->fetchAllObjects() as $obDTOProduto) $obDTOProduto->nome;
$obProduto->fetchColumn();
$obProduto->rowCount();
$obProduto->getLastInsertId();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.