Re: Calling custom methods in related models

2010-03-10 Thread WebbedIT
We all have moments where we are sure there is something wrong with
Cake, but most of the time it's our implementation of Cake :)

Glad you found it.

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-09 Thread mathaios
Ok, I've done some other tests and...I've found the problem.

The problem is that I'm stupid.

'className' = 'SisField',
should be instead
'className' = 'SiS.SisField',

it's even in the manuali do not understand how i could overlook
thisi need a vacation!

thanks very much to all anyway for the support!

On 8 Mar, 10:16, WebbedIT p...@webbedit.co.uk wrote:
 Andy is asking you to remove your className and foreign_key
 definitions to allow cake to try and define that relationship for you,
 but as I believe your definitions to completely follow convention I'm
 not sure how that will help in this case.

 I run MilesJ's forum plugin in my site and from that I am calling
 related models without issue so I very much doubt this is a bug with
 the core when using plugins.

 Yo8u say this only happens when calling a related model from a
 controller, my guessing is it will do this when calling a related
 model from a model too.  For some reason Cake is not finding your
 model, you need to play around with renaming it etc. to eventually get
 to the bottom of it.  Are all your other models working ok, is it just
 this one?

 HTH

 Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-08 Thread WebbedIT
Andy is asking you to remove your className and foreign_key
definitions to allow cake to try and define that relationship for you,
but as I believe your definitions to completely follow convention I'm
not sure how that will help in this case.

I run MilesJ's forum plugin in my site and from that I am calling
related models without issue so I very much doubt this is a bug with
the core when using plugins.

Yo8u say this only happens when calling a related model from a
controller, my guessing is it will do this when calling a related
model from a model too.  For some reason Cake is not finding your
model, you need to play around with renaming it etc. to eventually get
to the bottom of it.  Are all your other models working ok, is it just
this one?

HTH

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-07 Thread mathaios
I can confirm that all the related models called from a controller
(like $this-contr1-contr2) are automatically re-generated by
Cakephp. I can say that because I have some configuration done in
other model's relations declaration that get overwritten and lost
too.  I think this is a plug-in only issue, as far I rembember I did
not face this problem before. I will give a try to 1.2.6 and if the
problem remains try to move the models and controllers outside the
plug-in.

 What happens if you change SisField::$hasMany to var $hasMany =
 array('SisQueue');?

pardon for my dumbness but I did not understand what you are asking me
to do...in the model hasMany is already var hasMany=



 On Mar 6, 9:02 pm, mathaios mathaio...@gmail.com wrote:

  yes Paul this is the problem!

  $this-SisField-SisQueue-belongsTo does return an empty array
  instead of the real one. Clearly Cake is auto-creating the model.
  I have tested all other model related to SisField and none of them is
  the real one: all are re-created by Cake.

  Maybe it's related of this being a plug-in and could be a bug ?

  On Mar 6, 8:41 am, WebbedIT p...@webbedit.co.uk wrote:

   That looks correct to me, to test if the problem is with the function
   name put() I just added a method to one of my models and called it via
   another model from a controller without issue so that's not the
   problem.

   Can you access any of that models attributes/methods?  how about :

   echo debug($this-SisField-SisQueue-belongsTo);

   I think that cake is not finding the model for some reason and is
   therefore creating it's own auto-model which obviously will not
   include the put() method.  Confusing as your model's filename seems to
   be correct, but the above should test this.

   HTH

   Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-07 Thread Andy Dirnberger
  What happens if you change SisField::$hasMany to var $hasMany =
  array('SisQueue');?

 pardon for my dumbness but I did not understand what you are asking me
 to do...in the model hasMany is already var hasMany=


I'm asking you to change $hasMany from what you have to the shorter
version I posted.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-06 Thread mathaios
yes Paul this is the problem!

$this-SisField-SisQueue-belongsTo does return an empty array
instead of the real one. Clearly Cake is auto-creating the model.
I have tested all other model related to SisField and none of them is
the real one: all are re-created by Cake.

Maybe it's related of this being a plug-in and could be a bug ?

On Mar 6, 8:41 am, WebbedIT p...@webbedit.co.uk wrote:
 That looks correct to me, to test if the problem is with the function
 name put() I just added a method to one of my models and called it via
 another model from a controller without issue so that's not the
 problem.

 Can you access any of that models attributes/methods?  how about :

 echo debug($this-SisField-SisQueue-belongsTo);

 I think that cake is not finding the model for some reason and is
 therefore creating it's own auto-model which obviously will not
 include the put() method.  Confusing as your model's filename seems to
 be correct, but the above should test this.

 HTH

 Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-06 Thread Andy Dirnberger
What happens if you change SisField::$hasMany to var $hasMany =
array('SisQueue');?

On Mar 6, 9:02 pm, mathaios mathaio...@gmail.com wrote:
 yes Paul this is the problem!

 $this-SisField-SisQueue-belongsTo does return an empty array
 instead of the real one. Clearly Cake is auto-creating the model.
 I have tested all other model related to SisField and none of them is
 the real one: all are re-created by Cake.

 Maybe it's related of this being a plug-in and could be a bug ?

 On Mar 6, 8:41 am, WebbedIT p...@webbedit.co.uk wrote:



  That looks correct to me, to test if the problem is with the function
  name put() I just added a method to one of my models and called it via
  another model from a controller without issue so that's not the
  problem.

  Can you access any of that models attributes/methods?  how about :

  echo debug($this-SisField-SisQueue-belongsTo);

  I think that cake is not finding the model for some reason and is
  therefore creating it's own auto-model which obviously will not
  include the put() method.  Confusing as your model's filename seems to
  be correct, but the above should test this.

  HTH

  Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-05 Thread WebbedIT
It appears the error he is getting is the error you get when calling a
model's method that has not been defined or mistyping it's name when
you do this it attempts to run a query with that method name and kicks
the following error

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'unknownMethodName ' at line 1 [CORE\cake\libs
\model\datasources\dbo_source.php, line 527]

Query: unknownMethodName

In order to kick this message out it is finding the model, but the
method being called does not exist.

HTH

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-05 Thread mathaios

This is model1 (in a is a plug-in,called sis) sis_field.php
?php
class SisField extends SisAppModel {

var $name = 'SisField';
var $belongsTo = array(
'SisContact' = array(
'className' = 'SisContact',
'foreignKey' = 'sis_contact_id'
)
);

var $hasMany = array(
'SisQueue' = array(
'className' = 'SisQueue',
'foreignKey' = 'sis_field_id'
)
);

}
?

This is model 2, put does not do much yet because I was stopped from
the error
(sis_queue.php)
?php
class SisQueue extends SisAppModel {

var $name = 'SisQueue';
var $belongsTo = array(
'SisField' = array(
'className' = 'SisField',
'foreignKey' = 'sis_field_id',
'conditions' = '',
'fields' = '',
'order' = ''
)
);

function put($ids){
$q=$this-find('all');
return $q;
}

}
?

I call then the function from the SisField controller:
(sis_fields_controller.php)

$this-SisField-SisQueue-put($ids);

as you see it's all very simple...don't understand what I'm doing
wrong...for sure something that will make a fool out of me...

i I call the find statement from the controller everything is fine, so
the connection between the models are set-up correctly I think!


On 4 Mar, 18:58, Andy Dirnberger andy.dirnber...@gmail.com wrote:
 What is the actual name of model2 and what is its filename? If the
 file isn't being found, model2 is of type AppModel and not model2,
 which would explain why you can't access a method defined in model2.

 On Mar 4, 12:36 pm, mathaios mathaio...@gmail.com wrote:

  Hallo all bakers! I hope someone can help me...

  I have two models related trough a to many-belongs to relationships.
  I've set in model2 a method called put that do some db manipulation.

  But when I call the put method from the related model1 controller
  (as $this-model1-model2-put() ) the method name get's executed like
  an SQL query!
  But if I call something like e.g. $this-model1-model2-find('all')
  records are correctly fetched.

  What can be the problem? I'm getting mad on this !
  Thanks for any advice

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-05 Thread WebbedIT
That looks correct to me, to test if the problem is with the function
name put() I just added a method to one of my models and called it via
another model from a controller without issue so that's not the
problem.

Can you access any of that models attributes/methods?  how about :

echo debug($this-SisField-SisQueue-belongsTo);

I think that cake is not finding the model for some reason and is
therefore creating it's own auto-model which obviously will not
include the put() method.  Confusing as your model's filename seems to
be correct, but the above should test this.

HTH

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-04 Thread John Andersen
Please show the code that you have in the put method.
Enjoy,
   John

On Mar 4, 7:36 pm, mathaios mathaio...@gmail.com wrote:
 Hallo all bakers! I hope someone can help me...

 I have two models related trough a to many-belongs to relationships.
 I've set in model2 a method called put that do some db manipulation.

 But when I call the put method from the related model1 controller
 (as $this-model1-model2-put() ) the method name get's executed like
 an SQL query!
 But if I call something like e.g. $this-model1-model2-find('all')
 records are correctly fetched.

 What can be the problem? I'm getting mad on this !
 Thanks for any advice

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Calling custom methods in related models

2010-03-04 Thread Andy Dirnberger
What is the actual name of model2 and what is its filename? If the
file isn't being found, model2 is of type AppModel and not model2,
which would explain why you can't access a method defined in model2.

On Mar 4, 12:36 pm, mathaios mathaio...@gmail.com wrote:
 Hallo all bakers! I hope someone can help me...

 I have two models related trough a to many-belongs to relationships.
 I've set in model2 a method called put that do some db manipulation.

 But when I call the put method from the related model1 controller
 (as $this-model1-model2-put() ) the method name get's executed like
 an SQL query!
 But if I call something like e.g. $this-model1-model2-find('all')
 records are correctly fetched.

 What can be the problem? I'm getting mad on this !
 Thanks for any advice

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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