- Messages
- 164
- Reaction score
- 0
- Points
- 26
TS inaaral mo din ba yung source code mismo ng cakePHP o wapakels na lang??
Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.
All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!
TS inaaral mo din ba yung source code mismo ng cakePHP o wapakels na lang??
Inaaral din... kailangan mu din basahin yung code nya para mas maintindihan mu kung panu nangyayari lahat ng mga procedure jan
ang haba kaya non......
ts i have two tables....
1-Division
2-Employee
c employee ay isa sa mga part nang division at ang division ay categorized
ang employee table may foreign key na 'divisionID'
ang tanong ko ts....ano ang gagamitin kon association linking?....sa bawat model ng table...
salamat...
sir what if need ng debugkit?
pano sya install?
employee belongsTo division
diviosn hasMany employee
For referrence please use this manual. Associations: Linking Models Together
sori po busy lang po di ako updated dito :'(
ito po oh https://github.com/cakephp/debug_kit
Employee AppModel
<?php
class Employee extends AppModel{
var $name = 'Employees';
public $belongsTo = array(
'Positions' => array(
'className' => 'Position',
'foreignKey' => 'positions_id'
)
);
}
?>
***********************************************
Employee controller function add()
public function add(){
if($this->request->is('post')){
$this->Employee->save($this->request->data);
$this->Session->setFlash('Employee have been save.');
$this->redirect(array('action' => 'index'));
}
$this->set('positions',$this->Employee->Position->find('list', array('fields' => ('Position.positionName'))));
}
*******************************************
add.ctp
<div>
<?php
echo $this->Form->create('Employee');
echo $this->Form->input('empId');
echo $this->Form->input('lastName');
echo $this->Form->input('firstName');
echo $this->Form->input('middleInitial');
echo $this->Form->input('positions_id');
echo $this->Form->end('Save');
?>
</div>
***********************************************
error po cya "Call to a member function find() on a non-object "
pa help ts..
var $name = 'Employees'; //wrong
var $name = 'Employee'; //correct
$this->set('positions',$this->Employee->Position->find('list', array('fields' => ('Position.positionName'))));
//see $this->Employee
pa join din dito TS...pa assist nalng if may problem..
Check your Employee model
Code:var $name = 'Employees'; //wrong var $name = 'Employee'; //correct
and
Code:$this->set('positions',$this->Employee->Position->find('list', array('fields' => ('Position.positionName')))); //see $this->Employee
NOTE : Model name should be in Singular form
**Sorry po kung late reply**
$this->set('positions',$this->Employee->Position->find('list', array('fields' => ('Position.positionName'))));
$this->loadModel('Position');
$this->set('positions',$this->Position->find('list', array('fields' => ('Position.positionName'))));
$this->loadModel('Division');
$this->set('divisions', $this->Division->find('list', array('fields' => ('Division.divisionName'))));
$this->loadModel('Company');
$this->set('companys', $this->Company->find('list', array('fields' => ('Company.companyName'))));
TS i don't know kung bakit gumagana parin ang ginawa ko gamit plural ang MODEL na gamit ko...
para sa code na ito
Code:$this->set('positions',$this->Employee->Position->find('list', array('fields' => ('Position.positionName'))));
ang ginawa ko ay ito
Code:$this->loadModel('Position'); $this->set('positions',$this->Position->find('list', array('fields' => ('Position.positionName')))); $this->loadModel('Division'); $this->set('divisions', $this->Division->find('list', array('fields' => ('Division.divisionName')))); $this->loadModel('Company'); $this->set('companys', $this->Company->find('list', array('fields' => ('Company.companyName'))));
i load the model..