Plural, CamelCased, and end in Controller
Multiple word controllers can be any ‘inflected’ form which equals the controller name so:
/redApples
/RedApples
/Red_apples
/red_apples
will all resolve to the index of the RedApples controller.
The convention is that your URLs are lowercase and underscored, therefore /red_apples/go_pick is the correct form to access the RedApplesController::go_pick action.
In general, filenames match the class names, which are CamelCased. . So if you have a class MyNiftyClass, then in CakePHP, the file should be named MyNiftyClass.php.
Below are examples of how to name the file for each of the different types of classes you would typically use in a CakePHP application:
- The Controller class
KissesAndHugsControllerwould be found in a file namedKissesAndHugsController.php - The Component class
MyHandyComponentwould be found in a file namedMyHandyComponent.php - The Model class
OptionValuewould be found in a file namedOptionValue.php - The Behavior class
EspeciallyFunkableBehaviorwould be found in a file namedEspeciallyFunkableBehavior.php - The View class
SuperSimpleViewwould be found in a file namedSuperSimpleView.php - The Helper class
BestEverHelpewould be found in a file namedBestEverHelper.php
Courtesy: http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html
<?php
$this->User->find( 'all', array(
'conditions' => array("not" => array ( "User.site_url" => null)
))Courtesy: http://stackoverflow.com/a/1197000/749232
<?php
if ( ! empty($projectid)) {
$listOptions['conditions'] = array(
'OR'=>array(
array(
'project_id' => $projectid,
'not'=>array('project_id' => null)
),
array('project_id' => null)
)
);
}
$auditList = $this->Audit->find('all', $listOptions);-- The resultant query will look like:
SELECT `Audit`.`id`, `Audit`.`event`, `Audit`.`model`, `Audit`.`entity_id`, `Audit`.`project_id`, `Audit`.`json_object`, `Audit`.`description`, `Audit`.`user_id`, `Audit`.`entity_name`, `Audit`.`created`
FROM `galaxy3`.`audits` AS `Audit`
WHERE (
(
(
(`project_id` = '1234') AND (
NOT (`project_id` IS NULL)
)
)
)
OR (`project_id` IS NULL)
)Courtesy:
- http://stackoverflow.com/questions/14645584/cakephp-1-3-multiple-and-or-conditions-in-find
- http://stackoverflow.com/questions/17783248/multiple-conditions-in-find-all
<?php
$this->loadModel('<pluginname>.<modelname>');
?>