Skip to content

Instantly share code, notes, and snippets.

@ceeram
ceeram / gist:6395301
Created August 30, 2013 23:44
setDbConfig
public function setDbConfig($source = null, $useTable = null) {
$this->getDataSource()->flushMethodCache();
if ($source) {
$this->oldSource = array('useTable' => $this->useTable, 'useDbConfig' => $this->useDbConfig);
$this->setDataSource($source);
if ($useTable !== null) {
$this->setSource($useTable);
}
} else {
if ($this->oldSource) {
comment_char %
escape_char /
%
% Dutch Language Locale for the Netherlands
% Source: RAP
% Address: Sankt Jo//rgens Alle 8
% DK-1615 Ko//benhavn V, Danmark
% Contact: Keld Simonsen
% Email: Keld.Simonsen@dkuug.dk
% Tel: +45 - 31226543
@ceeram
ceeram / AppModel.php
Created August 21, 2013 16:09
rawSave()
<?php
App::uses('Model', 'Model');
class AppModel extends Model {
public $saveTemplate = 'INSERT INTO `%s` (%s) VALUES %s;';
public function rawSave($data) {
if(empty($data)) {
@ceeram
ceeram / find.php
Last active December 18, 2015 03:59
<?php
public function specificAccessSpeeds() {
$specificAccessType_id = $this->request->data['Service']['specific_access_type_id'];
$Model = ClassRegistry::init('SpecificAccessTypesAccessSpeed');
$Model->virtualFields['custom'] = 'AccessSpeed.name';
$specificAccessSpeeds = $Model->find( 'list', array(
'conditions' => array( 'SpecificAccessTypesAccessSpeed.specific_access_type_id' => $specificAccessType_id ),
'recursive' => -1,
@ceeram
ceeram / user.ctp
Last active December 15, 2015 02:58
<?php $user = $this->Session->read('Auth.User');?>
<?php if (!$user) : ?>
<?php echo $this->Form->create('User', array('novalidate' => true, 'url' => array('controller' => 'users', 'action' => 'login', 'plugin' => false, 'admin' => false)));?>
<?php echo $this->Form->input('username');?>
<?php echo $this->Form->input('password');?>
<?php echo $this->Form->end('Login');?>
<?php else : ?>
@ceeram
ceeram / gist:5060990
Last active December 14, 2015 08:49
dataProvider outside test class
<?php
/**
* Provider Test Case
*
*/
class ProviderTest extends PHPUnit_Framework_TestCase {
/**
*
@ceeram
ceeram / trait.php
Created November 17, 2012 17:53 — forked from lorenzo/trait.php
trait foo { function bob() { echo 'from trait'; }}
class bar { use foo { bob as likeBob }; function bob() { $this->likeBob();}}
class baz extends bar { function bob() { parent::bob(); echo ' from child'; }}
$a = new baz;
$a->bob();
//result: from trait from child
@ceeram
ceeram / gist:3852324
Last active October 11, 2015 11:28
cakephp submodule
cd to app
git submodule add git://github.com/ceeram/cakephp.git Core
<optional>
cd Core
git checkout 2.4
cd ..
</optional>
//update webroot/index.php:
@ceeram
ceeram / ModelSaveAllTest.php
Created October 2, 2012 23:20
ModelSaveAllTest.php
<?php
/**
* ModelWriteTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
@ceeram
ceeram / Odbc.php
Created July 6, 2012 21:05
Odbc datasource CakePHP for Throughbred odbc connection. UNSTABLE
<?php
/**
* ODBC for DBO
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License