How do I get a record saved in the Cakephp database

1

Good evening, how do I get a specific field in my table. I wanted to get this field and get into a variable and show in the view. Thank you !!

    
asked by anonymous 31.01.2015 / 01:44

1 answer

3

Is the view relative to the same table model or different? If it's the same:

 $total = $sales['Sale']['valor'];

If it is different, in the controller of your view, it is:

 public function view(){
         $this->loadModel('Sale');
            $sales = $this->Sale->find('list', array('fields' => array('Sale.valor')));
            $this->set('valor', $valor);

Then in view.ctp:

 $total = $valor['Sale']['valor'];
    
13.02.2015 / 18:53