Skip to content

Instantly share code, notes, and snippets.

View lorenzo's full-sized avatar

José Lorenzo Rodríguez lorenzo

View GitHub Profile
/**
* Override default updateAll to workaround forced joins
*
* @return void
*/
public function updateAll($fields, $conditions = true) {
$name = $this->name;
$this->name = '_model_';
try {
array(
'User' => array(
),
'Availability' => array(
(int) 0 => array(
'day_id' => (int) 1,
'timeslot_id' => (int) 1,
'user_id' => (int) 1
),
(int) 1 => array(
class AppController extends Controller {
public $components = array(
'Session',
'Cookie',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'userModel' => 'Member',
'fields' => array('username' => 'pseudo', 'password' => 'password')
)
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<?php
define('LOOP',1000000);
class ClassA {
}
function a($arg1, ClassA $arg2=null, ClassA $arg3=null, ClassA $arg4=null) {};
function b($arg1, $arg2=null, $arg3=null, $arg4=null) {};
function f1() {
@lorenzo
lorenzo / routes.php
Last active August 29, 2015 14:02 — forked from archanavhire/routes.php
Capitalizing controller names
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<?php
$query
->clause('where')
->traverse(function($exp) {
$exp->iterateParts(function($part) {
if ($part instanceof Comparison && $part->getField() === 'type') {
return new QueryExpression([$part, ['id IN' => $ids]], [], 'OR');
}
});
})
<?php
class User extends Entity {
public function isAdmin() {
return $this->role === 'admin';
}
}