Skip to content

Instantly share code, notes, and snippets.

View andrebian's full-sized avatar

Andre Cardoso andrebian

View GitHub Profile
<?php
public function beforeFind($queryData)
{
parent::beforeFind($queryData);
// Verifica se o primeiro campo da ordenação está setado
if (!empty($queryData['sort']) && $queryData['sort'] == 'primeiro_campo') {
// Caso esteja, adiciona o segundo elemento junto à ordenação padrão
<?php
function get_posts_by_category( $category_name )
{
$args = array(
'posts_per_page' => 30,
'offset' => 0,
'category' => $category_name,
'orderby' => 'post_date',
'order' => 'DESC',
<?php
//Código
$terms = get_categories(array(
'type' => 'represent_map',
'taxonomy' => 'represent_map_type')
);
$categories = array();
<?php
//Definindo a ordenação da paginação por dois itens
/**
*
* @param array $queryData
* @return array
*/
public function beforeFind( $queryData )
<?php
$this->Filter->addFilters('Filtro', array('LIKE' => __('contendo', true)));
$this->Filter->setPaginate('limit', 6); // opcional
$this->Filter->setPaginate('group', 'Qname.queue');
$this->Filter->setPaginate('fields', array('COUNT(QueueStat.qname) as Total', 'Qname.queue', 'Qevent.event', 'Qevent.event_id'));
$this->Filter->setPaginate('conditions', $this->Filter->getConditions());
$this->QueueStat->recursive = 0;
$this->set('queuestats', $this->paginate());
@andrebian
andrebian / ExcelExportExample.php
Created April 1, 2014 01:00
Um pequeno exemplo de como exportar em XLS (Excel) usando PHP.
<?php
header('Content-Type: text/html; charset=utf-8');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header ('Last-Modified: ' . gmdate("D,d M YH:i:s") . ' GMT');
header ('Cache-Control: no-cache, must-revalidate');
header ('Pragma: no-cache');
header ('Content-type: application/x-msexcel');
header ('Content-Disposition: attachment; filename="' . date('Y-m-d_H-i-s') . '.xls"');
header ("Content-Description: PHP Generated Data" );
<?php
class PagesController extends AppController {
public function beforeFilter()
{
// habilita todas as actions
$this->Auth->allow();
// habilita actions especificas
php -r "readfile('https://getcomposer.org/installer');" | php
curl -sS https://getcomposer.org/installer | php
{
"name": "Finanças Pessoais",
"description": "Uma API para gerenciamento de finanças pessoais",
"authors": [
{
"name": "Andre Cardoso",
"email": "andrecardosodev@gmail.com"
}
],
"require": {