WELL WELL..hehe.. nice trick you had ther..i read the manual aboyt
HABTM's with and kablamm!! it works..
so why is cake behaving things like that?they always used the word
"automagically" but then dont know how to
automagically interpret the names i used even i followed the
convention..or maybe i did something wrong somewhere..
for now,ill stick with the "with" key..hard to find the bug there(for
me)...
thank you guys...deadline is fast approaching..still nid to add auth
to my project...acos and aros are still
complicated for me this time..hehe

On Sep 8, 12:02 am, Martin Westin <martin.westin...@gmail.com> wrote:
> 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" <drlob...@gmail.com> 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 <lunaro...@gmail.com> 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
>
> > >                                                                           
> > >                               )
> > >                                                                           
> > >                       )
> > >                                ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to