Good afternoon

I'm using CakePHP to develop a system and would like to know how can I
use the ClassResitry: init () instead of $uses.

Currently the model of paper is as follows:

<?php


  class Livro extends AppModel{

     var $name                = 'Livro';
         var $Categoria           = ClassRegistry::int('Model','Categoria');
         var $hasAndBelongsToMany = array( 'Categoria' => array
(   'className'              => 'Categoria',
                                                                                
                                           'joinTable'              => 
'categorias_livros',
                                                                                
                                           'foreignKey'             => 
'livro_id',
                                                                                
                                           'associationForeignKey'  => 
'categoria_id',
                                                                                
                                           'unique'                 => true,
                                                                                
                                           'conditions'             => '',
                                                                                
                                           'fields'                 => '',
                                                                                
                                           'order'                  => '',
                                                                                
                                           'limit'                  => '',
                                                                                
                                           'offset'                 => '',
                                                                                
                                           'finderQuery'            => '',
                                                                                
                                           'deleteQuery'            => '',
                                                                                
                                           'insertQuery'            => '' ) );

  }
?>


I added the line in model:

         var $Categoria           = ClassRegistry::int('Model','Categoria');

And the Controller of this book thus:

<?php

  class LivrosController extends AppController{

   var $name           = 'Livros';
   var $helpers        = array( 'Html' , 'Form' , 'Javascript' ,
'Ajax' );
  // var $uses           = array( 'Categoria', 'Livro' );
   var $components     = array( 'RequestHandler' );

   function index(){
     $this->set('Livros', $this->Livro->find('all', array('fields' =>
array('Livro.id' , 'Livro.nome' ))));
   }

   function add(){


     $this->set('Categorias', $this->Categoria->find('all', array
('fields' => array( 'Categoria.id' , 'Categoria.nome' ))));

         $categoria = $this->data['Categoria'];

         for( $i = 0 ; $i <= ( count( $categoria ) - 1 ) ; $i++ ){
         if ( $categoria[$i]['categoria_id'] == 0 ) {
             $this->data['Categoria'] [$i]['categoria_id'] = Null;
          }
         }

         if( $this->Livro->saveAll( $this->data )){
                            $msg = sprintf('O curso %s foi editado com 
sucesso.',
$this->data['Livro']['nome'] );
                                        
$this->Session->setFlash($msg,'default', array('class'=>'ui-
corner-all sucesso'));
                                        //$this->redirect( array( 'controller' 
=> 'Livros', 'action' =>
'index') );
            print_r( $this->data );
           }
    }

  }

?>

I commented the line in Controller:
// var $uses           = array( 'Categoria', 'Livro' );

But when I enter the application, the following error is displayed on
the screen:

Parse error: parse error, expecting `','' or `';'' in C:\Program Files
\Apache Software Foundation\Apache2.2\htdocs\cakestudo\app\models
\livro.php on line 7

Thanks for help me.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.


Reply via email to