I was reading on cakebook but still did’nt understand. I’m having problems adding data to database so i want to check the result of my basic add function:
public function add() {
if ($this->request->is('post')) {
$this->Ficha->create();
if ($this->Ficha->save($this->request->data)) {
$this->Session->setFlash('Your post has been saved.');
//$last_id=$this->Ficha->getLastInsertID();
$this->redirect(array('action' => 'preencher_ficha'),$last_id);
} else {
$this->Session->setFlash('Unable to add your post.');
}
print_r($this->Ficha->save);
}
}
add.ctp file
<?php
echo $this->Form->create('Ficha', array('action' => 'index'));
echo $this->Form->input('cod_produto', array('label' => 'Código Produto:'));
echo $this->Form->input('nome_produto', array('label' => 'Nome Produto:'));
echo $this->Form->input('versao', array('label' => 'Versão:'));
echo $this->Form->input('data_ficha', array('label' => 'Data:'));
//echo $this->Form->input('body', array('rows' => '3'));
echo $this->Form->end('Criar Ficha');
?>
for that, i would like to use the $debug or $print_r so that after submit the form cakephp would show me where the problem is but i’m not using it correctly or maybe in the wrong “section”. Could anyone tell me which var should i use to print and what i should have between () of that var of output to print the result of the add function on the screnn?
Thank you!
You can do a couple debugging things here:
OR: