PHP code example of antoniosam / easy-doctrine

1. Go to this page and download the library: Download antoniosam/easy-doctrine 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/ */

    

antoniosam / easy-doctrine example snippets


$pagina = $request->get('pagina', 1);
$columna = $request->get('columna', null);
$orden = $request->get('orden', null);
$buscar = $request->get('buscar', null);

$campos = ['id','name' ,'lastname', 'email', 'gender','active', 'created_at'];
$col =  (!is_null($columna) && $columna != '')?$campos[$columna]:'id';
$ord = (!is_null($columna) && $columna != '')?$orden:'ASC';

$em = $this->getDoctrine()->getManager();
        
$paginar = new EasyDoctrine($em,Entity::class);
$paginar->setPage($pagina);
$paginar->where('active','=',true);
if(!empty($buscar)){
    $paginar->search($buscar,['name','email']);
}
$paginar->order($col,$ord);
$paginar->execute();

$info = $paginar->getResult()


$campos = ['municipio','delegacion','direccion', 'numero', 'colonia'];
$col =  (!is_null($columna)  $columna != '')?$campos[$columna]:'direccion';
$ord = (!is_null($columna)  $columna != '')?$orden:'ASC';
 
$paginar = new EasyDoctrine($em,Casa::class);
$paginar->setPage($pagina);
if(!empty($buscar)){
    $paginar->search($buscar,['direccion','colonia']);
}
if($col == 0){
    $paginar->leftJoin('delegacion','d');
    $paginar->leftJoin('municipio','m','d');
    $paginar->ordenar('nombre','ASC,'m');
}else{
    $paginar->ordenar('campo','ASC');
}
$paginar->execute();