I agree with the good doctor.
One detail you may not realise is that it matters little if if you
name the model correctly unless you also specify "with" on the
associations... and that you do it from both sides.

Unless you specify "with" and specify the Modelname Cake might be
loading AppModel (I believe this happened to me a few months ago even
though it shouldn't).

More definite is that you must specify "with" from both sides of the
habtm. If you do it only from one side you can be sure the other one
is loaded first and Cake chooses AppModel. From that point on there is
nothing you can do to bring up the real model since the AppModel will
be in the registry.

I noticed this when normal requests worked and shell access was messed
up... because the models were loaded in a different order.

/Martin


On Sep 8, 8:33 am, "Dr. Loboto" <[email protected]> wrote:
> Output get_class($this->EnrolleesOfferedSubject) in your controller.
> If it is AppModel cake cannot find your model file.
>
> On Sep 8, 10:32 am, learning_cake_php <[email protected]> wrote:
>
>
>
> > i already check my model names and codes...
> > i have a controller named EnrollmentController and from there
> > i used the $uses property for me to user the EnrolleesOfferedSubject
> > model..
> > why is it that save,create and delete method works just fine..saves
> > and delete to/from
> > correct table(enrollees_offered_subjects) but my custom method wont
> > work..here is the actual code:
>
> > //enrollment_controller.php
> > <?
> >         class EnrollmentController extends AppController {
> >                 var $name = 'Enrollment';
> >                 var $uses = array(
> >                                                 'Enrollment',
> >                                                 'Student',
> >                                                 'EnrollmentPayment',
> >                                                 'Enrollee',
> >                                                 'OfferedSubject',
> >                                                 'EnrolleesOfferedSubject',
> >                                                 'Major',
> >                                                 'Campus',
> >                                                 'College',
> >                                                 'Course',
> >                                                 'Subject',
> >                                                 'Program',
> >                                                 'Scholarship',
> >                                                 'Users'
> >                                         );
>
> >                 function subjectView(){
> >                         $this->setCRUD('subject');
>
> >                         
> > $student=$this->Student->isStudent($this->Session->read
> > ('Student.id'));
> >                         if(!$student){
> >                                 $this->Session->setFlash(__('Student Not 
> > Found.', true));
> >                                 $this->redirect(array('action'=>'index'));
> >                         }
>
> >                         $this->Session->write('Student.id', 
> > $student['Student']['id']);
> >                         $this->Session->write('Student.full_name', 
> > $student['Student']
> > ['last_name']
> >                                                                             
> >             .", ".$student['Student']['first_name']
> >                                                                             
> >             ." ".$student['Student']['middle_name']
> >                                                                             
> >             ." ".$student['Student']['sur_name']
> >                                                                             
> >             );
>
> >                         
> > $enrollmentPayment=$this->EnrollmentPayment->isPaid($this->Session-
>
> > >read('Student.id'));
>
> >                         if(!$enrollmentPayment){
> >                                 $this->Session->setFlash(__('Not Yet 
> > Paid.', true));
> >                                 
> > $this->redirect(array('action'=>'paymentAdd'));
> >                         }
>
> >                         
> > $enrollee=$this->Enrollee->isEnrolled($this->Session->read
> > ('Student.id'));
>
> >                         if(!$enrollee){
> >                                 $this->Session->setFlash(__('Student Not 
> > Yet Enrolled.', true));
> >                                 
> > $this->redirect(array('action'=>'enrolleeAdd'));
> >                         }
>
> >                         $this->EnrolleesOfferedSubject->recursive = 0;
> >                         //$this->EnrolleesOfferedSubject->unbindModel(array
> > ('belongsTo'=>array('Enrollee','OfferedSubject')));
> >                         
> > $this->EnrolleesOfferedSubject->bindModel(array('belongsTo'=>array(
> >                                         'Enrollee'=>array(
> >                                                 'foreignKey'=>'enrollee_id',
> >                                                 'type'=>'INNER'
> >                                         ),
> >                     'OfferedSubject'=>array(
> >                         'foreignKey'=>'offered_subject_id',
> >                                                 'type'=>'INNER'
> >                                         ),
> >                     'Subject'=>array(
> >                         'foreignKey'=>false,
> >                                                 'type'=>'INNER',
> >                         'conditions'=> array('Subject.id =
> > OfferedSubject.subject_id')
> >                                         )
> >                                         )
> >                                 )
> >                         );
> >                         $this->set('student_full_name',$this->Session->read
> > ('Student.full_name'));
> >                         
> > $this->set('student_id',$this->Session->read('Student.id'));
> >                         $this->set('enrolleesOfferedSubjects', 
> > $this->EnrolleesOfferedSubject->find('all', array(
>
> >                                                 'conditions' => array(
> >                                                         
> > 'EnrolleesOfferedSubject.enrollee_id' => $enrollee['Enrollee']
> > ['id'],
> >                                                         
> > 'EnrolleesOfferedSubject.campus_id' => $this->Enrollment->campusId,
>
> >                                                         )
> >                                                 )
> >                                         )
> >                                 );
> >                 }
> >                 function subjectResult(){
> >                         Configure::write('debug', '0');
> >                         $this->setCRUD('subject');
> >                         $searchKey=trim($this->data['searchKey']);
> >                         
> > $student=$this->Student->isStudent($this->Session->read
> > ('Student.id'));
> >                         if(!$student){
> >                                 $this->Session->setFlash(__('Session has 
> > expired. Please click
> > done and try again.', true));
> >                         }elseif (!empty($searchKey)){
> >                                 $this->OfferedSubject->recursive = 1;
> >                                 $this->set('offeredSubjects', 
> > $this->OfferedSubject->find
> > ('all',array(
> >                                                                             
> >                     'conditions'=>array(
> >                                                                             
> >                             'and'=>array(
> >                                                                             
> >                                     'Subject.code LIKE 
> > '=>$this->data['searchKey'].'%',
> >                                                                             
> >                                     'OfferedSubject.campus_id' => 
> > $this->Enrollment->campusId
>
> >                                                                             
> >                             )
> >                                                                             
> >                     )
> >                                                                             
> >             )
> >                                                                             
> >     )
> >                                                                         );
> >                                 $this->set('total', 
> > $this->OfferedSubject->find('count',array(
> >                                                                             
> >                     'conditions'=>array(
> >                                                                             
> >                             'and'=>array(
> >                                                                             
> >                                     'Subject.code LIKE 
> > '=>$this->data['searchKey'].'%',
> >                                                                        
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to