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
/** | |
* Constructor. Binds the model's database table to the object. | |
* | |
* @param integer|string|array $id Set this ID for this model on startup, can also be an array of options, see above. | |
* @param string $table Name of database table to use. | |
* @param string $ds DataSource connection name. | |
*/ | |
public function __construct($id = false, $table = null, $ds = null) { | |
parent::__construct($id, $table, $ds); | |
//verify that all children have a $role |
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 | |
//Controller | |
namespace App\Controller; | |
use App\Controller\AppController; | |
class ArticlesController extends AppController { | |
public function beforeRender(\Cake\Event\Event $event) { | |
parent::beforeRender($event); |
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
was the ability to edit the wrapping div in the FormHelper::input() dropped in favor of the groupContainer template or has it not been implemented |
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
was the ability to edit the wrapping div in the FormHelper::input() dropped in favor of the groupContainer template or has it not been implemented |
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 | |
//if i dont have the id but i have the email | |
$email = 'johndoe@example.com'; | |
$new_pass = 'cakephp2014' | |
$user_id = $this->field('id', array('email' => $email)); | |
$this->User->save(array('id' => $user_id, 'password' => Security::hash($new_pass); |
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('ConnectionManager', 'Model'); | |
$db = ConnectionManager::getDataSource('amazon'); | |
$books = $db->find('Books', array( | |
'title' => 'Harry Potter' | |
)); | |
debug($books); |
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
debug($genres_movies); | |
########## DEBUG ########## | |
array( | |
'Movie' => array( | |
'id' => '1726' | |
), | |
'Genre' => array( | |
'Genre' => array( | |
(int) 0 => (int) 28, | |
(int) 1 => (int) 12, |
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 | |
// in the User Model | |
App::uses('AppModel', 'Model'); | |
App::uses('SimplePasswordHasher', 'Controller/Component/Auth'); | |
class User extends AppModel { | |
public function beforeSave($options = array()) { | |
if (isset($this->data[$this->alias]['password'])) { | |
$passwordHasher = new SimplePasswordHasher(); | |
$this->data[$this->alias]['password'] = $passwordHasher->hash( |
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 Keyword extends MoviesAppModel { | |
public function __construct($id = false, $table = null, $ds = null) { | |
parent::__construct($id, $table, $ds); | |
$this->virtualFields['movies_count'] = sprintf( | |
'select count(*) from `keywords_movies` where `keywords_movies`.`keyword_id` = `%s`.`id', $this->alias | |
); | |
} | |
?> |
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
// routes.php | |
<?php | |
Router::parseExtensions('json', 'xml'); | |
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); | |
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); | |
CakePlugin::routes(); | |
require CAKE . 'Config' . DS . 'routes.php'; | |
?> | |
// AppController |
OlderNewer