Skip to content

Instantly share code, notes, and snippets.

View McGaiser's full-sized avatar

Michael Gaiser McGaiser

View GitHub Profile
$venues = $this->PrestigeLogs->PrestigeLogsItems->Venues->find('list')->contain(['Games'])->group(['Games.id'])->toArray();
Creates error:
Error: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'camarilla.Venues.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
SQL Query:
SELECT Venues.id AS `Venues__id`, Venues.domain_id AS `Venues__domain_id`, Venues.continuity_id AS `Venues__continuity_id`, Venues.game_id AS `Venues__game_id`, Venues.created AS `Venues__created`, Venues.modified AS `Venues__modified`, Games.id AS `Games__id`, Games.parent_id AS `Games__parent_id`, Games.lft AS `Games__lft`, Games.rght AS `Games__rght`, Games.name AS `Games__name`, Games.abbreviation AS `Games__abbreviation`, Games.description AS `Games__description`, Games.created AS `Games__created`, Games.modified AS `Games__modified` FROM venues Venues LEFT JOIN gam
//MembershipClassesTable.php
namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Cake\Model\Behavior\TreeBehavior;
class MembershipClassesTable extends AppTable {
public function initialize(array $config){
<?php
use Cake\Routing\Router;
Router::scope('/', function($routes) {
$routes->connect('/PrestigeLogs', ['controller' => 'PrestigeLogs', 'plugin'=>'Incentives']);
}
);
//From /cam-website/config/bootstrap.php
Plugin::load('Incentives', ['bootstrap' => false, 'routes' => true]);
//From /cam-website/config/routes.php
<?php
/**
public function editPrestige($id=null){
$prestigeLog = $this->PrestigeLogs->get($id,
['contain'=>[
'Members.Domains',
'PrestigeLogsItems'=> function ($q){
return $q->where(['approved_id IS NULL']);
}
]]);
@McGaiser
McGaiser / PrestigeLogController.php
Created December 18, 2015 11:40
Issues saving stuff
Controller:
public function editPrestige($id=null){
$prestigeLog = $this->PrestigeLogs->find()
->contain([
'Members.Domains',
'PrestigeLogsItems'=> function ($q){
@McGaiser
McGaiser / gist:c605780d54b62c78abbb
Last active August 29, 2015 14:07
New Widget issues
//This is my autocomplete widget
<?php
namespace App\View\Widget;
use Cake\View\Widget\WidgetInterface;
use Cake\View\Form\ContextInterface;
class Autocomplete implements WidgetInterface {
@McGaiser
McGaiser / gist:dca33db8faff47af1b3f
Created October 6, 2014 23:01
AssignmentTable Validator
public function validationDefault(Validator $validator) {
return $validator
->validatePresence('role_id')
->notEmpty('role_id', 'A role is required')
->add('role_id', [
'unique' => [
'rule' => function($value, $context){
//debug($context);
return $context['data']['isUnique'];
@McGaiser
McGaiser / gist:9ee33ff9e46dd1fb491c
Created September 25, 2014 19:45
getActions function
// src/Model/Table/ResourcesTable.php
namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\Validation\Validator;
use ReflectionClass;
class ResourcesTable extends AppTable {
@McGaiser
McGaiser / gist:edf27674ca3632414514
Created September 25, 2014 19:21
get_class_methods results
array (size=59)
0 => string 'initialize' (length=10)
1 => string 'validationDefault' (length=17)
2 => string 'initializeDb' (length=12)
3 => string '__construct' (length=11)
4 => string 'defaultConnectionName' (length=21)
5 => string 'table' (length=5)
6 => string 'alias' (length=5)
7 => string 'connection' (length=10)
8 => string 'schema' (length=6)