This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppModel extends Model { | |
public function sort($ids, $orderField = 'order') { | |
if ($ids && is_array($ids)) { | |
$count = count($ids); | |
$query = array(); | |
$query[] = "UPDATE `{$this->table}`"; | |
$query[] = "SET `{$orderField}` = CASE `{$this->primaryKey}`"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds some NoSQL flavour to any RDBMS that Cake supports | |
* | |
* Need to create a new table with the following schema... | |
* | |
* CREATE TABLE IF NOT EXISTS `options` ( | |
* `id` int(11) NOT NULL auto_increment, | |
* `model` varchar(32) NOT NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::import('Inflector'); | |
class SluggableBehavior extends ModelBehavior { | |
private $_settings = array(); | |
function setup(&$model, $settings = array()) { | |
$default = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* EasyGD - A simple class to handle images in PHP with GD | |
* | |
* Basic Usage: | |
* | |
* $image = new EasyGD('image.jpg'); | |
* $image->crop(100, 50) | |
* ->width(50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bar extends AwesomeClass { | |
const FOO = 'Foo'; | |
public $bar = 'Bar'; | |
protected $var = 'Var'; | |
private $secret = 'Secret'; | |
public function init() { | |
$this->myFunction('Foo'); | |
echo(self::FOO); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Alloy; | |
class Request { | |
protected $schema = 'http'; | |
protected $host = 'localhost'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "LedControl.h" | |
// Infra red pin | |
const int irPin = 13; | |
// Global variables | |
int previousIrVal = HIGH; // The previous value of the IR reading. HIGH by default | |
int gameOn = 1; // If the game is running or not. It's on by default | |
int score = 0; // Initial score | |
int time = 0; // Elapsed time playing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('Cache', 'Cache'); | |
class PowerCache { | |
public static function write($key, $value, $config = 'default', $groups = []) { | |
if (!empty($groups)) { | |
$groups = !is_array($groups) ? [$groups] : $groups; | |
$groupsConfig = !empty(Configure::read('powercache.config')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppModel extends Model { | |
public function beforeValidate($options = array()) { | |
$this->_setupSetters(); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Cron\CronExpression; | |
App::uses('AppShell', 'Console/Command'); | |
class CronShell extends AppShell { | |
protected $_tasks = []; |
OlderNewer