Reputation: 1536
My table:
CREATE TABLE CS_GRPUSU (
GRPUSU NUMERIC(3,0) NOT NULL,
DESGRP VARCHAR(20)
);
ALTER TABLE CS_GRPUSU ADD PRIMARY KEY (GRPUSU);
How should be constructed my controller and model (file names and basic content)? Could someone give me examples?
Thanks!
Upvotes: 1
Views: 770
Reputation: 1540
Your model class should be defined like:
model:
class Example extends AppModel {
public $useTable = 'CS_GRPUSU'; // This model uses table 'CS_GRPUSU'
public $primaryKey = 'GRPUSU'; //for cakephp 1.3 use 'var' instead of 'public'
}
controller:
class Test exptends AppController{
public $uses = array('Example');
public function add(){
//your code
}
}
if you are using cakephp 1.3 then please replace public keyword with var
like
var $uses = array('Example');//cakephp 1.3
public $uses = array('Example'); //cakephp 2 and above
Upvotes: 2