Re: Find() failing due to '2006: MySQL server has gone away'

2012-04-16 Thread Kro
This isn't something which I have considered. I am not familiar with 
creating VIEWS. The tables which are queried are not static, the content 
can change all the time. Would a VIEW be appropriate in this situation?

On Monday, 19 March 2012 20:13:57 UTC, cricket wrote:

 Perhaps you need to optimize your query/indexes. Have you considered
 creating a (database) view?

 On Wed, Mar 14, 2012 at 7:32 PM, Kro yenohamonin...@gmail.com wrote:
  I have a find() call which sometimes takes a long time to complete,
  depending on the date range selected by the user. This can sometimes 
 cause
  the server to time out (2006: MySQL server has gone away), causing the
  find() to fail. I have tried altering the timeout value using the 
 following:
  ini_set('mysql.connect_timeout', 5);
 
  My presumption is that this is failing because I cannot override the 
 server
  settings on the hosting package.
  I was advised by the hosting company to use the following code:
  SET @@session.wait_timeout=60
 
  I would be very grateful for any advice on increasing the MySQL server
  timeout through CakePHP.
 
  --
  Our newest site for the community: CakePHP Video Tutorials
  http://tv.cakephp.org
  Check out the new CakePHP Questions site http://ask.cakephp.org and help
  others with their CakePHP related questions.
 
 
  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


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Repeated SQL Error: 2006: MySQL server has gone away

2012-04-10 Thread Kro
Hi,
I have a recurring issue with a CakePHP application. On a daily basis the 
error logs are showing  SQL Error: 2006: MySQL server has gone away  in 
[/home/t553788/public_html/res360/res/cake/libs/model/datasources/dbo_source.php.
 
I have contacted my hosting company and the MySQL server timeout value has 
been increased but this hasn't prevented the error from occurring. Has 
anybody any idea as to what else may be causing this and also how would I 
go about presenting a custom error to the user when this happens?
Kro

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Find() failing due to '2006: MySQL server has gone away'

2012-03-14 Thread Kro
I have a find() call which sometimes takes a long time to complete, 
depending on the date range selected by the user. This can sometimes cause 
the server to time out (2006: MySQL server has gone away), causing the 
find() to fail. I have tried altering the timeout value using the following:
ini_set('mysql.connect_timeout', 5); 

My presumption is that this is failing because I cannot override the server 
settings on the hosting package.
I was advised by the hosting company to use the following code:
SET @@session.wait_timeout=60

I would be very grateful for any advice on increasing the MySQL server 
timeout through CakePHP.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Do I need to load a Model if I reference it in a contain?

2012-03-12 Thread Kro
I have removed 'var $uses' from a controller and replaced it with
calls to 'loadModel()'. I'm just wondering if I need to load a model
which isn't referenced directly in a function, but is referenced in a
contain.
e.g.

$contain =
array('SurveyResponse'=array('SurveyQuestion'),'BookingOrder'=array('Room','Rate','AddOnPurchase'=array('AddOn')));
 //
Association between Booking and SurveyResponse in SurveyResponse Model
$this-Booking-contain($contain);

Is it necessary to load the 'SurveyResponse' Model as it is mentioned
in the above contain statement for the Booking Model?

Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Do I need to load a Model if I reference it in a contain?

2012-03-12 Thread Kro
Thanks for the reply. So in the above scenario (contain reference to
'SurveyRespose') I would need to load the 'SurveyResponse' Model as it
is not related to the 'Booking' Model?

On Mar 12, 2:25 pm, euromark dereurom...@googlemail.com wrote:
 no
 not if there is a relation between those models and you properly access it
 via chain:

     $this-Booking-SurveyResponse-find();
 etc

 Am Montag, 12. März 2012 13:32:32 UTC+1 schrieb Kro:









  I have removed 'var $uses' from a controller and replaced it with
  calls to 'loadModel()'. I'm just wondering if I need to load a model
  which isn't referenced directly in a function, but is referenced in a
  contain.
  e.g.

  $contain =
  array('SurveyResponse'=array('SurveyQuestion'),'BookingOrder'=array('Room 
  ','Rate','AddOnPurchase'=array('AddOn')));
  //
  Association between Booking and SurveyResponse in SurveyResponse Model
  $this-Booking-contain($contain);

  Is it necessary to load the 'SurveyResponse' Model as it is mentioned
  in the above contain statement for the Booking Model?

  Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Do I need to load a Model if I reference it in a contain?

2012-03-12 Thread Kro
Okay, I obviously need to get a better understanding of
'contain'...thanks again for taking the time...

On Mar 12, 11:34 pm, euromark dereurom...@googlemail.com wrote:
 well, If you use it inside a contain there has to be a relation present!
 either in the model - hardcoded in $hasMany/$belongsTo or dynamically via
 bindModel()

 but without the relation definition the containable behavior doesnt know
 what to do with it.

 Am Montag, 12. März 2012 13:32:32 UTC+1 schrieb Kro:









  I have removed 'var $uses' from a controller and replaced it with
  calls to 'loadModel()'. I'm just wondering if I need to load a model
  which isn't referenced directly in a function, but is referenced in a
  contain.
  e.g.

  $contain =
  array('SurveyResponse'=array('SurveyQuestion'),'BookingOrder'=array('Room 
  ','Rate','AddOnPurchase'=array('AddOn')));
  //
  Association between Booking and SurveyResponse in SurveyResponse Model
  $this-Booking-contain($contain);

  Is it necessary to load the 'SurveyResponse' Model as it is mentioned
  in the above contain statement for the Booking Model?

  Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Find condition on Date field

2012-02-29 Thread Kro
Hi,
I am trying to filter a VIEW by month and year using separate drop
lists. My code works fine if a year and month selection is made but I
want to be able to filter based on a selection in either one, i.e. not
force a selection of both.
As it stands I am concatenating the year and month selections (day is
always 01) as follows:

$sel_date = $sel_year.'-'.$sel_month.'-01';
$conditions = array('MonthlyReturn.month' = $sel_date); ---note
MonthlyReturn.month is actually a DATE field

I tried $conditions = array('MonthlyReturn.month.YEAR' = $sel_year);

Is it possible to add a condition which only searches by either month
or year?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Find condition on Date field

2012-02-29 Thread Kro
Found the solution, not sure if it is the Cake way of doing it but it
works.
$conditions = array('YEAR(MonthlyReturn.month)' = $sel_year); ---
match by year only
$conditions = array('MONTH(MonthlyReturn.month)' = $sel_month); ---
match by month only

On Feb 29, 10:32 am, Kro yenohamonin...@gmail.com wrote:
 Hi,
 I am trying to filter a VIEW by month and year using separate drop
 lists. My code works fine if a year and month selection is made but I
 want to be able to filter based on a selection in either one, i.e. not
 force a selection of both.
 As it stands I am concatenating the year and month selections (day is
 always 01) as follows:

 $sel_date = $sel_year.'-'.$sel_month.'-01';
 $conditions = array('MonthlyReturn.month' = $sel_date); ---note
 MonthlyReturn.month is actually aDATEfield

 I tried $conditions = array('MonthlyReturn.month.YEAR' = $sel_year);

 Is it possible to add aconditionwhich only searches by either month
 or year?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Form helper issue with euro symbol

2012-02-28 Thread Kro
Hi,
I have a form input which is taking in a rate title. This has worked
fine in the past but when a euro symbol is added to a title Cake
doesn't seem to be converting it to 'euro' as I would expect. The
core file, layout and database are all using utf-8 encoding. I'm just
wondering if there is some parameter I can add to the form input field
to force Cake to convert the euro before saving?
Any advice would be greatly appreciated...

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Issue with Form Helper array('type' = 'file')

2012-02-25 Thread Kro
Thank you so much, it's working now! You were spot on, it was the
Couplers beforesave that was unsetting the data. I have stopped it
doing that now and I can't see why that would cause any other issues.




The change I have made is as follows:
function beforeSave($Model) {
if (!$Model-exists()) {
if (!isset($Model-data[$Model-alias]['file'])) {
removed unset ---                  //unset($Model-data[$Model-
alias]);
return true;
}
} else {
if (isset($Model-data[$Model-alias]['delete'])
 $Model-data[$Model-alias]['delete'] !== '0') {
$Model-delete();
unset($Model-data[$Model-alias]);
return true;
}
}


Thanks again...



On Feb 24, 5:48 pm, jeremyharris funeralm...@gmail.com wrote:
 Okay I think I misspoke. You do need the coupler. (Sorry lack of docs and
 it's been a while since I had to configure.)

 I'd stick some debug statements through all of the behaviors' beforeSave
 calls to try and figure out what's happening. I'm suspicious that the rate
 data is being removed in Coupler's beforeSave due to some issue with the
 'file' key not being there or not being validated. This will hopefully give
 you a better understanding of what's going on.







 On Friday, February 24, 2012 1:02:05 AM UTC-8, Kro wrote:

  Thanks for your reply. Okay, sounds like it could be related to the
  Coupler then. I tried removing the Coupler and the 'Rate' data is then
  saving correctly but the image is missing. I am using 'dirname' and
  'basename' fields in the 'Rate' table rather than using a separate
  Attachment table, does this mean I don't need the Coupler element?

  On Feb 24, 2:19 am, jeremyharris funeralm...@gmail.com wrote:
   What behaviors are you using besides Transfer? Coupler tends to mess
  with
   the data because it expects *just* the fields in the Media.Attachment
   model. Try removing Coupler if it's attached (since you're not using
  it).

   Also, unit tests are your friend. It would be much easier to try things
  and
   debug using unit tests rather than not.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Issue with Form Helper array('type' = 'file')

2012-02-25 Thread Kro
Couldn't have done it without you...cheers...

On Feb 25, 8:17 pm, jeremyharris funeralm...@gmail.com wrote:
 Awesome, glad you figured it out!







 On Saturday, February 25, 2012 10:48:59 AM UTC-8, Kro wrote:

  Thank you so much, it's working now! You were spot on, it was the
  Couplers beforesave that was unsetting the data. I have stopped it
  doing that now and I can't see why that would cause any other issues.

  The change I have made is as follows:
  function beforeSave($Model) {
                  if (!$Model-exists()) {
                          if (!isset($Model-data[$Model-alias]['file'])) {
          removed unset ---
   //unset($Model-data[$Model-
  alias]);
                                  return true;
                          }
                  } else {
                          if (isset($Model-data[$Model-alias]['delete'])
                           $Model-data[$Model-alias]['delete'] !== '0')
  {
                                  $Model-delete();
                                  unset($Model-data[$Model-alias]);
                                  return true;
                          }
                  }

  Thanks again...

  On Feb 24, 5:48 pm, jeremyharris funeralm...@gmail.com wrote:
   Okay I think I misspoke. You do need the coupler. (Sorry lack of docs
  and
   it's been a while since I had to configure.)

   I'd stick some debug statements through all of the behaviors' beforeSave
   calls to try and figure out what's happening. I'm suspicious that the
  rate
   data is being removed in Coupler's beforeSave due to some issue with the
   'file' key not being there or not being validated. This will hopefully
  give
   you a better understanding of what's going on.

   On Friday, February 24, 2012 1:02:05 AM UTC-8, Kro wrote:

Thanks for your reply. Okay, sounds like it could be related to the
Coupler then. I tried removing the Coupler and the 'Rate' data is then
saving correctly but the image is missing. I am using 'dirname' and
'basename' fields in the 'Rate' table rather than using a separate
Attachment table, does this mean I don't need the Coupler element?

On Feb 24, 2:19 am, jeremyharris funeralm...@gmail.com wrote:
 What behaviors are you using besides Transfer? Coupler tends to mess
with
 the data because it expects *just* the fields in the
  Media.Attachment
 model. Try removing Coupler if it's attached (since you're not using
it).

 Also, unit tests are your friend. It would be much easier to try
  things
and
 debug using unit tests rather than not.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Issue with Form Helper array('type' = 'file')

2012-02-24 Thread Kro
Thanks for your reply. Okay, sounds like it could be related to the
Coupler then. I tried removing the Coupler and the 'Rate' data is then
saving correctly but the image is missing. I am using 'dirname' and
'basename' fields in the 'Rate' table rather than using a separate
Attachment table, does this mean I don't need the Coupler element?

On Feb 24, 2:19 am, jeremyharris funeralm...@gmail.com wrote:
 What behaviors are you using besides Transfer? Coupler tends to mess with
 the data because it expects *just* the fields in the Media.Attachment
 model. Try removing Coupler if it's attached (since you're not using it).

 Also, unit tests are your friend. It would be much easier to try things and
 debug using unit tests rather than not.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Issue with Form Helper array('type' = 'file')

2012-02-23 Thread Kro
I am saving a Rate record and an associated image using the Media
plugin (https://github.com/davidpersson/media). Everything works fine
when an image is added, when an image isn't added the Rate record gets
corrupted.

The array is as follows:

Array ( [Rate] = Array ( [enabled] = 0 [is_corporate] = 0
[special_offer] = 0 [list_no] = 0 [id_ref] = 43564566 [title] =
rate7 [price_quote_as] = 0 [adult_supplement] = 0 [child_supplement]
= 0 [supplement] = 0 [short_description] = rate7 [description] =

rate7
[available] = Array ( [0] = 2 ) [minimum_stay] = 0 [maximum_stay]
= 0 [valid_from] = 2012-02-24 [valid_to] = 2012-02-25 [file] =
Array ( [name] = [type] = [tmp_name] = [error] = 4 [size] = 0 ) )
[Room] = Array ( [Room] = Array ( [0] = 16 ) ) )

Note the 'file' array with the error 4.

Any help would be greatly appreciated.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Issue with Form Helper array('type' = 'file')

2012-02-23 Thread Kro
Thanks for taking the time to reply @jeremyharris. The record is still
getting written but the 'Rate' data is missing. The following is an
example of a saved record. As you can see the 'Rate' data is missing.

Array
(
[Rate] = Array
(
[id] = 92
[id_ref] =
[title] =
[short_description] =
[description] =
[price_quote_as] =
[adult_supplement] = 0.00
[child_supplement] = 0.00
[supplement] = 0.00
[minimum_stay] = 0
[maximum_stay] = 0
[imagefile] =
[enabled] = 0
[special_offer] = 0
[list_no] = 0
[availability] =
[valid_from] = -00-00 00:00:00
[valid_to] = -00-00 00:00:00
[is_corporate] = 0
[created] = -00-00 00:00:00
[updated] = -00-00 00:00:00
[deleted] = 0
[dirname] =
[basename] =
)

[Room] = Array
(
[0] = Array
(
[id] = 15
[title] = Deluxe Double Room
[description] = Situated in the new wing of
[min_adults] = 2
[max_adults] = 2
[max_children] = 0
[no_of_rooms] = 0
[enabled] = 1
[list_no] = 2
[created] = 2011-09-04 21:37:08
[updated] = 2011-09-05 17:00:55
[deleted] = 0
[dirname] = img
[basename] = deluxe_bedroom_2.jpg
[RatesRoom] = Array
(
[id] = 1942
[rate_id] = 92
[room_id] = 15
[dirname] =
[basename] =
)

)

)

[CorporateAccount] = Array
(
)

)

On Feb 23, 3:34 pm, jeremyharris funeralm...@gmail.com wrote:
 What do you mean by corrupted? It should fail gracefully and stop the save
 process if there's an error.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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