Skip to content

Instantly share code, notes, and snippets.

View henrikbjorn's full-sized avatar

Henrik Hauge Bjørnskov henrikbjorn

View GitHub Profile
<?php
class Forum extends AppModel
{
var $actsAs = array('Containable');
var $hasMany = array(
'Forums' => array(
'className' => 'Forum',
'foreignKey' => 'parent_id',
SELECT `Message`.`id`, `Message`.`user_id`, `Message`.`sender_id`, `Message`.`status`, `Message`.`title`, `Message`.`body`, `Message`.`parent_id`, `Message`.`created`, `Message`.`modified`, `Sender`.`id`, `Sender`.`username`, `Sender`.`password`, `Sender`.`created`, `Sender`.`modified`, `Sender`.`active`, `Sender`.`validate_key`, `Sender`.`email`, `Sender`.`status`, `User`.`id`, `User`.`username`, `User`.`password`, `User`.`created`, `User`.`modified`, `User`.`active`, `User`.`validate_key`, `User`.`email`, `User`.`status` FROM `messages` AS `Message` LEFT JOIN `users` AS `Sender` ON (`Message`.`sender_id` = `Sender`.`id`) LEFT JOIN `users` AS `User` ON (`Message`.`user_id` = `User`.`id`) WHERE (`Message`.`user_id` = 11 OR `Message`.`sender_id` = 11) AND ((`Message`.`status` & 8) = 0) ORDER BY `Message`.`modified` DESC, `Message`.`status` DESC
<?php
$array = array(
'key' => 'value',
'key2' => 'value',
);
//array as string
$string = serialize($array);
<?php
/**
* MeioUpload Behavior
* This behavior is based on Tane Piper's improved uplaod behavior (http://digitalspaghetti.tooum.net/switchboard/blog/2497:Upload_Behavior_for_CakePHP_12)
* @author Vinicius Mendes ([email protected])
* @link http://www.meiocodigo.com
* @filesource http://www.meiocodigo.com/meioupload
* @version 1.0.1
* @lastmodified 2008-10-04
*
<?php
class AppController extends Controller {
/**
* For controller, does magic
*
* @var array
*/
var $components = array('DebugKit.Toolbar', 'Session', 'Auth', 'Cookie', 'RequestHandler');
<?php
/**
* Abstract class to do some preconfiguration for all controllers
* extending this one.
*
* @package BaseApp
*/
abstract class Template_Controller extends Controller
{
public function register()
{
$this->View->errors = array();
$this->View->user = new User_Model;
if (request::method() == 'post') {
$this->View->user->load_values($this->input->post());
$this->View->user->password = $this->input->post('password');
if ($this->View->user->validate($this->input->post())) {
<?php
/**
* Abstract class to do some preconfiguration for all controllers
* extending this one.
*
* @package BaseApp
*/
abstract class Base_Controller extends Controller
{
Debate:
actAs:
Versionable:
auditLog: true
versionColumn: version
className: %CLASS%Version
Timestampable:
Sluggable:
fields: [title]
unique: true
<?php
class JsModuleActionFilter extends sfFilter
{
public function execute($filterChain)
{
if ($this->isFirstCall()) {
$params = $this->getContext()->getRequest()->getRequestParameters();
//gets a module action specific js file