Custom functions are not working in CakePhp 2.4.1

I am not able to read custom function in cakephp.

AkashSrivastava Default Asked on November 5, 2015 in Technology.
Add Comment
1 Answers

It’s not possible to give a directly-working answer because: There’s nothing wrong with the code in the question. That probably means you aren’t running your own code at all.

Given that the only answer that can be given is advice, the only class that matters for the example in the question is Owner.

Check filenames

The model conventions are:

The Model class OptionValue would be found in a file named OptionValue.php

Misnamed model files is by far the most common cause of “why is my model logic not being executed” questions. One pitfall is to add the suffix Model.php to model files, is the model file named correctly?

In this case check that the file app/Model/Clinic.php exists.

Verify that the model is your model

If you’re sure the model file is named correctly check what the app is using:

debug(get_class($this->Clinic));########## DEBUG ##########'Clini'###########################

If the output is “AppModel” – the model file is not loaded. There are very few reasons why CakePHP will not use a file that exists and one of them will apply:

  • The file does not exist – there is a typo in the name
  • The application is not looking in the same directory you are
  • The application doesn’t have permission to open the file

Verify the association exists

debug($this->Clinic->hasMany);########## DEBUG ########## array('Car'=> array('className'=>'Car','foreignKey'=>'owner_id','conditions'=>'','fields'=>'','order'=>'','limit'=>'','offset'=>'','dependent'=>'','exclusive'=>'','finderQuery'=>'','counterQuery'=>''))###########################

If Car is not in the output – the association isn’t saved because to cake it doesn’t exist – you’ll need to identify why.

For more info : http://stackoverflow.com/questions/21910150/cakephp-does-not-use-my-models

admin Administrator Answered on November 5, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.