Re: pagination with join and array in cakephp

2015-02-23 Thread ajt


   I still cant get this to work with paginate but i can with find all 
 , so there has to be a way

 

$options['recursive'] =-1;
  


  I still cant get this to work with paginate but i can with find all , 
 so there has to be a way

 
   $options['recursive'] =-1;
 

 


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


pagination with join and array in cakephp

2015-02-22 Thread ajt
Hi, in cakephp I used a 'find all' to do a complex and this works fine as 
below. My issue is I am trying to convert this to a set  paginated results 
and I keep getting offset warning Illegal offset type 
[CORE\Cake\Model\Model.php, line 2936.
I am sure the issue is simple but is there a way to to do this with the 
$option arrays I have for the search . I didnt see an example in the docs 
for the paginate results with an array set for the options
 
http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html

   $this-Lesson-recursive = -1;
 

$options['joins'] = array(
array('table' = 'lessons_students',
'alias' = 'LessonsStudent',
'type' = 'LEFT',
'conditions' = array(
'Lesson.id = LessonsStudent.lesson_id',
 )
 ),

   array('table' = 'students',
'alias' = 'Student',
'type' = 'LEFT',
'conditions' = array(
'LessonsStudent.student_id=Student.id',
 )
 ),
   array('table' = 'subjects',
'alias' = 'Subject',
'type' = 'LEFT',
'conditions' = array(
'Lesson.subject_id=Subject.id',
 )
 ),
   array(
'table' = 'tutors',
'alias' = 'Tutor',
'type' = 'LEFT',
'conditions' = array(
'Lesson.tutor_id = Tutor.id'
)
)  ,
  array('table' = 'tutoring_types',
'alias' = 'TutoringType',
'type' = 'LEFT',
'conditions' = array(
'Lesson.tutoring_type_id=TutoringType.id',
 )
 )
);

  $options['fields'] = 
array('Student.last_name','Student.first_name','Student.id',
'Lesson.lesson_date', 'Lesson.start_time', 
'Lesson.end_time', 
'Lesson.id','Lesson.schedule_rec','Lesson.schedule_monthly','Lesson.schedule_yearly',
  'Lesson.cancelled_by', 'Lesson.makeup_lesson', 
'Lesson.tutoring_type_id', 'Lesson.forefit',
'LessonsStudent.*',
'Tutor.last_name', 'Tutor.first_name','Tutor.id',
'Subject.name','Subject.id',
'TutoringType.*');

  
  
 $options['conditions'] = array('Lesson.lesson_inactive' = 
0,'Lesson.makeup_lesson' = 0,'Lesson.forefit' = 0,
 'Lesson.lesson_date = ' = $startdate,  
'Lesson.lesson_date = ' = $enddate,
  'AND' =array(
  array('OR' = array(
   array('Student.first_name LIKE'  = 
'%' . $searchFirstName  . '%'),
   array('Tutor.first_name LIKE'  = 
'%' . $searchFirstName  . '%'),
   array('Student.guardian_first_name 
LIKE'  = '%' . $searchFirstName  . '%'),
),
  array('OR' = array(
   array('Student.last_name LIKE'  = 
'%' . $searchLastName  . '%'),
   array('Tutor.last_name LIKE'  = '%' 
. $searchLastName  . '%'),
   array('Student.guardian_last_name 
LIKE'  = '%' . $searchLastName  . '%'),
   
) ,
array('OR' = array(
   array('Student.student_mobile LIKE'  
= '%' . $searchmobile  . '%'),
   array('Tutor.mobile LIKE'  = '%' . 
$searchmobile   . '%'),
   array('Student.guardian_mobile 
LIKE'  = '%' . $searchmobile   . '%'),
   
)   
  
  
  
  );

$options['order'] 
=array('Lesson.lesson_date','Lesson.start_time'); 
 $options['limit'] =150;
  $options['page'] =1;
 
   //$lessons= $this-Lesson-find('all', $options ); 
  
  $options['recursive'] =50;
 
   $this-Paginator-settings = array($options);
   
  $lessons= $this-Paginator-paginate('Lesson');

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed