saveall on habtm creates duplicate new rows

2015-06-10 Thread ajt
Hi, I have a simple HABTM  with a lessons/Students table. i simply create a 
new lesson with an existing student via a while loop , so I should get 2 
new rows. I am testing this function. What I get is 4 new rows in the 
lesson table instead of 2. I have no idea why the extra 2 rows are created 
as they are a duplicates of the 2 new rows which are outputted in debug. 
Everything is correctly saved like the entries in join lesson/student table 
and all the FK exist.

Just to add confusion, sometimes the same code produces the desired 2 rows 
. This is unstable so I am doing something wrong. I followed the array 
setup for habtm as in the manual for saves.

http://book.cakephp.org/2.0/en/models/saving-your-data.html

 private function book_lessons($lesson=null) {

   // debug( $lesson);
 
 $i=0;
 while ($i<2)
 {
  $date=date('Y-m-d');
  $data[$i]=array();
  
  
  $data[$i]['Lesson']['lesson_date']= $date;
  $data[$i]['Lesson']['start_time']= 
$lesson['Lesson']['start_time'];
  $data[$i]['Lesson']['end_time']=$lesson['Lesson']['end_time'];

  $data[$i]['Lesson']['schedule_rec']= 1;
  $data[$i]['Lesson']['subject_id']= 
$lesson['Lesson']['subject_id'];
  $data[$i]['Lesson']['tutoring_type_id']= 1;
  $data[$i]['Lesson']['tutor_id']= $lesson['Lesson']['tutor_id'];
  $data[$i]['Lesson']['subject_id']= 
$lesson['Lesson']['subject_id'];
  $data[$i]['Lesson']['term_id']= $lesson['Lesson']['term_id'];

  $data[$i]['Student']['id']=$lesson['Student']['id'];
 
 $i=$i+1;
 
 }
 

  $this->Lesson->saveAll($data);

public $hasAndBelongsToMany = array(

'Student' => array(
'className' => 'Student',
'joinTable' => 'lessons_students',
'foreignKey' => 'lesson_id',
'associationForeignKey' => 'student_id',
'unique' => 'keepExisting',

)
);


array(
(int) 0 => array(
'Lesson' => array(
'lesson_date' => '2015-06-11',
'start_time' => '16:00:00',
'end_time' => '17:00:00',
'schedule_rec' => (int) 1,
'subject_id' => '16',
'tutoring_type_id' => (int) 1,
'tutor_id' => '12',
'term_id' => '10'
),
'Student' => array(
'id' => '206'
)
),
(int) 1 => array(
'Lesson' => array(
'lesson_date' => '2015-06-11',
'start_time' => '16:00:00',
'end_time' => '17:00:00',
'schedule_rec' => (int) 1,
'subject_id' => '16',
'tutoring_type_id' => (int) 1,
'tutor_id' => '12',
'term_id' => '10'
),
'Student' => array(
'id' => '206'
)
)
)

-- 
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.


Re: Console, shell and cronjob woes

2015-06-10 Thread Andras Kende
Hi Paul,

The 777 indeed the quick fix of doing it :(

try the official:  http://book.cakephp.org/2.0/en/installation.html#permissions 

or 
https://www.google.com/#q=cakephp+tmp+777 



Andras

> On Jun 10, 2015, at 4:01 AM, phpMagpie  wrote:
> 
> @Andras: You should avoid using 777 as that gives read/write/execute access 
> to the world, which is a major security concern.
> 
> Further information on this:
> 
> When a web page loads, any files written/updated within tmp folders are given 
> apache:apache (user:group) access.
> 
> When a cronjob runs, any files written/updated within tmp folders are given 
> user:user (user:group) access.  
> 
> If apache cannot read/write from these files it can cause Fatal PHP errors 
> and web pages fail to load
> 
> If user cannot read/write from these files it can cause Fatal PHP errors 
> which cause cronjobs not to run
> 
> How do I create a setup where apache and user cronjobs can run and update tmp 
> files without breaking everything?
> 
> Thanks, Paul.
> 
> 
> 
> -- 
> 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 
> .

-- 
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.


Advise plugin to compress CSS and JS for cakephp 3.x

2015-06-10 Thread InYan
Advise plugin to compress CSS and JS for cakephp 3.x. 
In the old version of the framework I've used CakePHP-Combinator-Plugin 

But with cakephp 3.x it does not work.

-- 
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.


Re: Console, shell and cronjob woes

2015-06-10 Thread phpMagpie
@Andras: You should avoid using 777 as that gives read/write/execute access 
to the world, which is a major security concern.

*Further information on this:*

When a web page loads, any files written/updated within tmp folders are 
given *apache:apache* (user:group) access.

When a cronjob runs, any files written/updated within tmp folders are given 
*user:user* (user:group) access.  

If *apache* cannot read/write from these files it can cause Fatal PHP 
errors and web pages fail to load

If *user* cannot read/write from these files it can cause Fatal PHP errors 
which cause cronjobs not to run

How do I create a setup where apache and user cronjobs can run and update 
tmp files without breaking everything?

Thanks, Paul.


-- 
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.