Skip to content

Instantly share code, notes, and snippets.

@gapple
gapple / my_model.php
Created December 5, 2012 18:38
CakePHP 1.3 model ordering
<?php
class MyModel extends AppModel {
public function __construct($id = false, $table = null, $ds = null) {
parent::__construct($id, $table, $ds);
$this->order = array(
$this->alias . '.weight ASC',
$this->alias . '.name ASC',
);
@gapple
gapple / routes.php
Created November 13, 2012 23:04
CakePHP routing based on slug
<?php
App::import('Lib', 'routes/SluggableRoute');
Router::connect(
'/path-alias/:slug/*',
array(
'controller' => 'controller_name',
'action' => 'action_name',
'model' => 'ModelName',
),
@gapple
gapple / find.php
Created July 10, 2012 22:37
Cake find with limit on relation
<?php
$this->Client->find('all', array(
'conditions' => array(
),
'joins' => array(
array(
'table' => 'projects',
'alias' => 'ProjectJoin',
'type' => 'INNER',
'conditions' => array(