CakePHP: How to call an action of another controller

App::uses(‘AppController’, ‘Controller’); App::uses(‘EmployeesController’, ‘Controller’); class ReportingController extends AppController { public function some(){ $Employees = new EmployeesController; $Employees->constructClasses(); $Employees->areasAssigned();//areasAssigned function is in the Employees controller. } }

CakePHP HABTM how to save data

[sql] CREATE TABLE IF NOT EXISTS `permissions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, `displayName` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) CREATE TABLE IF NOT EXISTS `roles` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `company_id` int(11) NOT NULL, `dashboard_type` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY `company_id` (`company_id`) … Read more

condition in find function cakephp

How to get data on condition that start time only have current year data: [php] $event = $this->Event->find(‘first’, array( ‘conditions’ => array( ‘Event.id’ => $targetEvent[‘Eventtarget’][‘event_id’], ‘Event.stage’ => ‘created’, ‘year(Event.startTime)’ => date(‘Y’) ), //this is the condition we have to check ‘fields’ => array(‘Event.startTime’, ‘Event.city’, ‘Event.zip’, ‘Event.employee_id’) )); [/php]

CakePHP cake bake command

step 1: set path to environment variable. like: C:\xampp\php;C:\xampp\htdocs\yourproject\lib\cake\console\; step 2: open command prompt and type cd C:\xampp\htdocs\yourproject\app  and press enter. step 3: now type cake bake now you can see the options there. you can continue accordingly.

How to store csv file to the database in cake php by coding

function admin_exceladd(){ if (!empty($this->data)) { if(is_uploaded_file($this->data[‘Webshop’][‘excelfile’][‘tmp_name’])){ move_uploaded_file($this->data[‘Webshop’][‘excelfile’][‘tmp_name’], ‘img/files/’.$this->data[‘Webshop’][‘excelfile’][‘name’]); $file = ‘img/files/’.$this->data[‘Webshop’][‘excelfile’][‘name’]; $handle = fopen($file, “r”); // read the 1st row as headings $header = fgetcsv($handle); // read each data row in the file $i = 0; // for the message while (($row = fgetcsv($handle)) !== FALSE) { $i++; $data = array(); $data1 = array(); // … Read more

Uploading files

CREATE TABLE my_files ( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(75) NOT NULL, type VARCHAR(255) NOT NULL, size INT(11) NOT NULL, data MEDIUMBLOB NOT NULL, created DATETIME, modified DATETIME, PRIMARY KEY (id) ); // app/models/my_file.php class MyFile extends AppModel { var $name = ‘MyFile’; } // app/views/my_files/add.ctp (Cake 1.2) echo $form->create(‘MyFile’, array(‘action’ => ‘add’, ‘type’ … Read more