eu tive esse problema esses dias, uma associação que nunca funcionava...
não sei se foi um código colado errado, ou algum update que estava no
meio do caminho (uso o nightly), mas resolveu tirando as opcoes vazias
das associações !!!
seu codigo:
var $belongsTo = array(
'Menu' => array('className' => 'Menu',
'foreignKey' => 'menus_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
....
);
limpando:
var $belongsTo = array(
'Menu' => array('className' => 'Menu',
'foreignKey' => 'menus_id'
),
....
);
Dê uma testada, e avise aqui se funcionou...
Spark!
2008/2/12 DrWinux <[EMAIL PROTECTED]>:
>
> pessoal já viram o seguinte, tenho um model que faz varias consultas
> com varios relacionamentos belongsTo, hasMany, hasAndBelongsToMany .
> mais é o seguinte so retorna o belongsTo, nos outras associações nem
> aparece o array, que deveria ser vazio. Deem uma olhada no model.
>
> <?php
> class Product extends AppModel {
>
> var $name = 'Product';
> var $useTable = 'products';
> var $validate = array(
> 'menus_id' => array(
> 'numeric' => array(
> 'rule' =>
> array('numeric'),
> 'message'
> => 'São permitidos apenas números.'
> ),
> 'not_empty' => array(
> 'rule' =>
> VALID_NOT_EMPTY,
> 'message'
> => 'Por favor preencha este campo.'
> ),
> ),
> 'category_id' => array(
> 'numeric' => array(
> 'rule' =>
> array('numeric'),
> 'message'
> => 'São permitidos apenas números.'
> ),
> 'not_empty' => array(
> 'rule' =>
> VALID_NOT_EMPTY,
> 'message'
> => 'Por favor preencha este campo.'
> ),
> ),
> 'titleProduct' => array(
> 'rule' => VALID_NOT_EMPTY,
> 'message' => 'Por favor preencha
> este campo.'
> ),
> 'stats' => array(
> 'rule' => array('numeric'),
> 'message' => 'Por favor selecione o
> status.'
> ),
> );
>
> //The Associations below have been created with all possible keys,
> those that are not needed can be removed
> var $belongsTo = array(
> 'Menu' => array('className' => 'Menu',
> 'foreignKey'
> => 'menus_id',
> 'conditions'
> => '',
> 'fields' =>
> '',
> 'order' => ''
> ),
> 'Category' => array('className' => 'Menu',
> 'foreignKey'
> => 'category_id',
> 'conditions'
> => '',
> 'fields' =>
> '',
> 'order' => ''
> )
> );
>
> var $hasMany = array(
> 'ProductsInformationCat' =>
> array('className' => 'ProductsInformationCat',
> 'foreignKey' => 'products_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => '',
> 'limit' => '',
> 'offset' => '',
> 'dependent' => '',
> 'exclusive' => '',
> 'finderQuery' => '
>
> SELECT
>
> `ProductsInformationCat`.`products_id` ,
> `ProductsInformationCat`.`information_cats_id` ,
> `ProductsInformationCat`.`value` ,
> `InformationCat`.`titleInformationCat`
>
>
> FROM `products_information_cats` AS `ProductsInformationCat`
>
>
> LEFT JOIN `information_cats` AS `InformationCat` ON
> ( `ProductsInformationCat`.`information_cats_id` =
> `InformationCat`.`id` )
> ',
> 'counterQuery' => ''
> ),
> );
> var $hasAndBelongsToMany = array(
> 'Asdadasdasd' => array('className' => 'Filename',
> 'joinTable' =>
> 'products_filenames',
> 'foreignKey' => 'products_id',
> 'associationForeignKey' =>
> 'filenames_id',
> 'unique' => true,
> 'conditions' => '',
> 'fields' => '',
> 'order' => '',
> 'limit' => '',
> 'offset' => '',
> 'finderQuery' => '',
> 'deleteQuery' => '',
> 'insertQuery' => ''
> )
> );
> }
> ?>
>
> Controller:
> uso a function paginate, tbm tentei co find e findAll
>
> e retorna o seguinte array
> Array
> (
> [0] => Array
> (
> [Product] => Array
> (
> [id] => 1
> [menus_id] => 3
> [category_id] => 9
> [titleProduct] => Gol 1000
> [descriptionProduct] => asdad asda sdas d
> [created] => 2008-02-06
> [modified] => 0000-00-00
> [stats] => 0
> )
>
> [Menu] => Array
> (
> [id] => 3
> [level] => 0
> [menus_id] => 0
> [titleMenu] => Veículos
> [varMenu] => veiculos
> [urlMenu] =>
> [orderMenu] => 0
> [flagTop] => 0
> [flagBottom] => 0
> [created] => 2008-02-05
> [modified] =>
> [stats] => 0
> )
>
> [Category] => Array
> (
> [id] => 9
> [level] => 1
> [menus_id] => 3
> [titleMenu] => Motos
> [varMenu] => motos
> [urlMenu] =>
> [orderMenu] => 0
> [flagTop] => 0
> [flagBottom] => 0
> [created] => 2008-02-06
> [modified] =>
> [stats] => 0
> )
>
> )
>
>
> não retornando as associações hasMany e hasAndBelongsToMany , ja virão
> esse erro.
> tentei deletar o model, mais pelo incrivel que parece, ele continua
> acessando o banco... (nunca vi isso)
>
> tbm tentei instalar meu script em outra pasta cake, mais continua a
> msm coisa...
> e se apago o belongsTo ele remove os array que são retornados no
> resultado...
>
> já viram isso?
> desde já agradeço.....
> >
>
--
[livesets] http://djspark.com.br/
[web] http://sydi.net
[filmes] http://melhoresfilmes.com.br
--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito no Grupo "Cake PHP Português"
em Grupos do Google.
Para postar neste grupo, envie um e-mail para [email protected]
Para cancelar a sua inscrição neste grupo, envie um e-mail para [EMAIL
PROTECTED]
Para ver mais opções, visite este grupo em
http://groups.google.com/group/cake-php-pt?hl=pt-BR
-~----------~----~----~----~------~----~------~--~---