Symbianize Forum

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!

CakePHP Tutorial

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 :thumbsup:

 
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......
 
ang haba kaya non......



mahaba nga pero para sayo din naman yun e... pwede mu naman hindi basahin yun.. hindi naman required yun... nasa sayo na yun kung gusto mu mag explore.. kung kuntento kana sa alam mu at nakikita mu e di ok :lol:


 
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...
 
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...




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 :'(






sir what if need ng debugkit?

pano sya install?



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..
 
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..




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**

 
Last edited:
pa join din dito TS...pa assist nalng if may problem..
 
TS pahelp naman dito sa URL rewriting.. Linux user kasi ako un nalang error ko sa installation..tnx po
 
Aun na aus ko na..hehehe...

Just enable the rewrite module for ur apache2 service...then change ur vhost settings to AllowOverride All..

Im using lamp stack pala :D
 
Last edited:


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**


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..
 
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..




Tama yang ginawa mu na yan... ganan dapat yun.. nag base lang ako dun sa una mung post na inaaccess mu yung Employee model gamit yung relative model nya... pag hindi relative ang ang isang model sa controller na ginagalawa mu you can use load('Model') or ClassRegistry::init(modelName)

 
hi sir. may alam po ba kayong tutorial site for cakePHP . ung mga nkikita ko kase medyo advance na ung lessons. :thanks:
 
Back
Top Bottom