Load balance CakePHP between 2 EC2 instances

2012-02-15 Thread kyutums
We are currently using CodeIgniter in another project. To handle large
traffic (we get around 60k pageviews per day), we load balance between
2 EC2 instances.

Is it possible to load balance using CakePHP as well? Also, would it
be easy to add another server in the cluster using 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


ENUM support in Form Helper magic field

2012-02-15 Thread תמר קליין
Hi

I added support for enum in Form Helper magic field.
It's creating select field by default, but 'radio' type will work too.

The patch fits cakePHP 2.0.6, but I think it is very ease to apply the
changes to other versions.


Tamar Klein
Atar + Plus

-- 
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
--- FormHelper.php	2012-02-15 00:32:56.674417720 +0200
+++ cakephp/lib/Cake/View/Helper/FormHelper.php	2012-02-15 09:49:45.768793621 +0200
@@ -954,6 +954,15 @@
 
 		$modelKey = $this-model();
 		$fieldKey = $this-field();
+		$fieldDef = $this-_introspectModel($modelKey, 'fields', $fieldKey);
+ 
+		$enum_values=array();
+		if(preg_match('/^enum\((.*)\)$/',$fieldDef['type'],$enum_values)) {
+			if(!isset($options['options'])) {
+$options['options'] = preg_split('/,/',preg_replace('/\'/','',$enum_values[1]));
+$options['options'] = array_combine($options['options'],$options['options']);
+			}
+		}
 
 		if (!isset($options['type'])) {
 			$magicType = true;
@@ -964,7 +973,7 @@
 $options['type'] = 'password';
 			} elseif (isset($options['checked'])) {
 $options['type'] = 'checkbox';
-			} elseif ($fieldDef = $this-_introspectModel($modelKey, 'fields', $fieldKey)) {
+			} elseif ($fieldDef) {
 $type = $fieldDef['type'];
 $primaryKey = $this-fieldset[$modelKey]['key'];
 			}
@@ -998,6 +1007,10 @@
 $options['type'] = 'select';
 			}
 
+			if (preg_match('/^enum\(/',$fieldDef['type'])) {
+$options['type'] = 'select';
+			}
+
 			if ($modelKey === $fieldKey) {
 $options['type'] = 'select';
 if (!isset($options['multiple'])) {


Problem with JsHelper

2012-02-15 Thread Diablo Sinfuego
I have a problem with Js that I cannot resolve. I am basically trying
to write a Hello, world app to learn how to use this feature.

When I click on my submit button the first time, everything works.
When I click on the same button the second time, it blows up trying to
go to what appears to be a null controller:

Missing Controller
Error: Controller could not be found.
Error: Create the class Controller below in file: app/Controller/
Controller.php
?php
class Controller extends AppController {
}

Here is my Controller:

public function check($id = false) {
if (!empty($this-request-data)) {
if ($this-RequestHandler-isAjax()) {
$this-set('result', 'Hello, world');
$this-render('result', 'ajax');
}
}
}

Here is my View:

?php echo $this-Html-script('jquery', array('inline' = false)); ?
?php
echo $this-Form-create();
echo $this-Js-submit('Check', array('update' =
'#success'));
echo $this-Form-end();
?
div id=success/div
div id=checking style=display: none;Checking.../div
?php echo $this-Js-writeBuffer(); ?

JsHelper is generating the following JavaScript:

script type=text/javascript
//![CDATA[
$(#submit-549405557).bind(click, function (event) {$.ajax({data:$
(#submit-549405557).closest(form).serialize(), dataType:html,
success:function (data, textStatus) {$(#success).html(data);},
type:post, url:\/hosts\/check});
return false;});
//]]
/script

I'm stumped why it works on the first click but not the second.

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


Logic to join data to string before write to DB. Anyone help?

2012-02-15 Thread diendannhatban
Hello,

I would like to join data to string before write to DB.  Anyone help
me solve this out please. Thank you!

The data from form will look like this
[Event] = Array
(
[mark] = Array
(
[0] = 1
[1] = 2
[2] = 3
[3] = 4
)
   )

The following code will join the data to 1,2,3,4 string before
writing it to the db
// join type into csv
if(!empty($this-data['Event']['mark'])) {
$this-data['Event']['mark'] = join(',', $this-data['Event']
['mark']);
}


*My Problem:
The form data of mine after editing for a good view it will return
like this.
I would like to join the value to the string like the code about. How
would I solve the problem?

[Schedule] = Array
(
[1] = Array
(
[mark] = 1
)

[2] = Array
(
[mark] = 2
)

[3] = Array
(
[mark] = 3
)

[4] = Array
(
[mark] = 4
)

)

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


Undefined index with associated afterFind()

2012-02-15 Thread Ralph stokes
I'm using cakePHP 2.0 afterFind() callback to perform calculations on
database values before it is displayed.

I have three models - Materials, Products and Quotes.

Each product has a material and calculations are performed in the
Product afterFind callback using this association, specifically with
the line:

$results[$key]['Product']['material_cost'] = $results[$key]['Product']
['material_mass'] * $val['Material']['cost'];
with $val['Material']['cost'] referring to the associated material.

All fine so far.

Next I have an afterFind() callback in my Quote model. The quote is
associated with a product and the calculations in the quote model are
dependant on the calculations in the Product model taking place -
specifically the one which referances the material.

I can reference the Product model afterfind results in the Quote model
afterFind just fine like: $val['Product']['number_tools']

However, now the Product model cannot find the associated material and
I get the error: Undefined index: Material [APP/Model/Product.php,
line 126].
on line 126 of Product.php is

$val['Material']['cost']
How can I get around this problem, it's driving me nuts!

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


Auth.redirect - still problems with external links

2012-02-15 Thread René Weber
Hi there,

after searching and reading through existing Posts, I still have not
found an answer to my Problem:

I am running Cake 1.3 and using Auth Component for every page.

If I open a page directly by entering http://myserver/posts/view/123
he will redirect me to login and after successful login he will
present post 123 to me.
If I open a page by clicking on a link with the same URL, he will
redirect me to login and afterwars to /

Therese is NO AutoRedirect-false and there I even removed my Routes
for testing.
When I dump Auth.redirect, I will find an empty variable when coming
from external Links.

Any Ideas?

-- 
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: Logic to join data to string before write to DB. Anyone help?

2012-02-15 Thread euromark
you can always use foreach(){} - basic PHP one-o-one


On 15 Feb., 14:08, diendannhatban lecaoquoch...@gmail.com wrote:
 Hello,

 I would like to join data to string before write to DB.  Anyone help
 me solve this out please. Thank you!

 The data from form will look like this
 [Event] = Array
         (
             [mark] = Array
                 (
                     [0] = 1
                     [1] = 2
                     [2] = 3
                     [3] = 4
                 )
        )

 The following code will join the data to 1,2,3,4 string before
 writing it to the db
 // join type into csv
                 if(!empty($this-data['Event']['mark'])) {
                 $this-data['Event']['mark'] = join(',', $this-data['Event']
 ['mark']);
                 }

 *My Problem:
 The form data of mine after editing for a good view it will return
 like this.
 I would like to join the value to the string like the code about. How
 would I solve the problem?

 [Schedule] = Array
         (
             [1] = Array
                 (
                     [mark] = 1
                 )

             [2] = Array
                 (
                     [mark] = 2
                 )

             [3] = Array
                 (
                     [mark] = 3
                 )

             [4] = Array
                 (
                     [mark] = 4
                 )

         )

-- 
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: Auth.redirect - still problems with external links

2012-02-15 Thread euromark
what do you expect Auth.redirect to be when you come from an external
link?


On 15 Feb., 15:48, René Weber web_r...@gmx.de wrote:
 Hi there,

 after searching and reading through existing Posts, I still have not
 found an answer to my Problem:

 I am running Cake 1.3 and using Auth Component for every page.

 If I open a page directly by enteringhttp://myserver/posts/view/123
 he will redirect me to login and after successful login he will
 present post 123 to me.
 If I open a page by clicking on a link with the same URL, he will
 redirect me to login and afterwars to /

 Therese is NO AutoRedirect-false and there I even removed my Routes
 for testing.
 When I dump Auth.redirect, I will find an empty variable when coming
 from external Links.

 Any Ideas?

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


restricting afterFind() to one method

2012-02-15 Thread Charles Bueche
Hi,

I'm using cakePHP 2.1beta.

I had like to use the afterFind() in a model to massage some data.
However, I would like to restrict its effect to only one method defined
in the controller, and do nothing for the other methods. My initial
though was to do something like this :

function afterFind($results) {
if ($this-method == 'my_special_method') {
foreach ($results as $key = $val) {
# massage data
}
return $results;
}
else {
# no massaging
   return $results;
  }
}

but apparently, $this does not contain the calling method. Any idea ?

Thanks,
Charles

-- 
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: restricting afterFind() to one method

2012-02-15 Thread euromark
you could make this a behavior and only attach it in the methods/
actions you want it to work


On 15 Feb., 16:25, Charles Bueche cbli...@bueche.ch wrote:
 Hi,

 I'm using cakePHP 2.1beta.

 I had like to use the afterFind() in a model to massage some data.
 However, I would like to restrict its effect to only one method defined
 in the controller, and do nothing for the other methods. My initial
 though was to do something like this :

     function afterFind($results) {
         if ($this-method == 'my_special_method') {
             foreach ($results as $key = $val) {
                 # massage data
             }
             return $results;
         }
         else {
             # no massaging
            return $results;
       }
     }

 but apparently, $this does not contain the calling method. Any idea ?

 Thanks,
 Charles

-- 
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: Auth.redirect - still problems with external links

2012-02-15 Thread René Weber
I'd actually expect to be redirected to the page I wanted to visit
initially if using an external link. But it seems like the link is not
stored anywhere.

Means:
1. I click a link which points to http://myserver/posts/view/123
2. Cake will mention that there is no login yet and redirect me to the
login page
3. After providing my login credentials I press login
4. I'd expect to be forwarded to posts/view/123 but I am forwarded
to /

Unfortunatelly it seems like if he does not remember the string 'posts/
view/123' in step 2, if I am using a link. If I enter it into the
adress bar it works fine - the link string is stored to Auth.redirect.
But when I dump Auth.redirect after having clicked a link instead of
having entered it manually, it is empty.


Right now I have to right-click each link, copy link location,

On 15 Feb., 16:06, euromark dereurom...@googlemail.com wrote:
 what do you expect Auth.redirect to be when you come from an external
 link?

 On 15 Feb., 15:48, René Weber web_r...@gmx.de wrote:







  Hi there,

  after searching and reading through existing Posts, I still have not
  found an answer to my Problem:

  I am running Cake 1.3 and using Auth Component for every page.

  If I open a page directly by enteringhttp://myserver/posts/view/123
  he will redirect me to login and after successful login he will
  present post 123 to me.
  If I open a page by clicking on a link with the same URL, he will
  redirect me to login and afterwars to /

  Therese is NO AutoRedirect-false and there I even removed my Routes
  for testing.
  When I dump Auth.redirect, I will find an empty variable when coming
  from external Links.

  Any Ideas?

-- 
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: Problem with JsHelper

2012-02-15 Thread Diablo Sinfuego
This may have been a 2.0.0 problem. I just upgraded to 2.0.6 and the
problem seems to have gone away.

-- 
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: Problem with JsHelper

2012-02-15 Thread Diablo Sinfuego
Ok, now what's happening is the first time the submit button is
pressed it processes
and sends the Ajax request to the Controller. The second time the same
submit button
is pressed without reloading the page first, nothing happens.
Reloading the page
causes the submit button to work again.

Is there some sort of reset that needs to be done between button
presses?

I'm not sure if these is a Cake Js issue or a browser issue.

On Feb 15, 9:54 am, Diablo Sinfuego adwo...@netawareinc.com wrote:
 This may have been a 2.0.0 problem. I just upgraded to 2.0.6 and the
 problem seems to have gone away.

-- 
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: Retrieve all errors message from model validators

2012-02-15 Thread jeremyharris
Cake only returns the message of the last failed rule, as explained 
here: 
http://book.cakephp.org/2.0/en/models/data-validation.html#multiple-rules-per-field

-- 
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: Undefined index with associated afterFind()

2012-02-15 Thread jeremyharris
Maybe your original find didn't include that association. Check recursive 
or contain to make sure it should be included in the first place. Then 
debug the results in afterFind and the results where you originally called 
the find. 

-- 
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: restricting afterFind() to one method

2012-02-15 Thread jeremyharris
Remember that there's a separation between controllers and models. The 
model really doesn't need to know the method (and really shouldn't). I 
agree with euromark, attach it within the methods you want to use it. Or, 
attach it in beforeFilter for a little more organization.

-- 
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: Problem with JsHelper

2012-02-15 Thread Diablo Sinfuego
Getting closer... Found this post on another site:

  Okay after some research I found out that the 2nd submission is a
black-hole'd one.
  I dont know really why but after editing the code several times
Firebugs says that the
  2nd request is an 404 Error with an HTML answer including the Black-
Hole errors :/

I loaded up Firebug and sure enough, here are the results:

First Submit: 200 OK
Second Submit: 404 Not Found

On the second submit, it is actually returning all of the HTML
including all of the Cake errors of missing controller, like it did in
version 2.0.0. But now it seems to be noticing the 404 and just
tossing the results.

Anyhow with a lot of knowledge in JsHelper know why the first submit
works, yet the second one doesn't? I'm starting to suspect some sort
of incompatibility with the Security helper.

-- 
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: Problem with JsHelper

2012-02-15 Thread Diablo Sinfuego
Think I have this licked... The problem was with the Security CSRF
protection. If you're set up to use a token only once,
your second Ajax request will get black-holed because the token has
expired.

I'm not sure if this is the best way to handle multiple Ajax requests
with CSRF, but it seems to work. I added the
following to my Controller to ignore CSRF for this particular action:

public function beforeFilter() {
if ($this-action == 'check') {
$this-Security-csrfCheck = false;
}
}

It now lets me process multiple requests without having to reload the
page.

-- 
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: Load balance CakePHP between 2 EC2 instances

2012-02-15 Thread John Hardy
No sticky sessions, through my experience with load balancing my particular 
cakePHP application ( and various others ) I've found that sticky sessions does 
not evenly balance the load across machines, particularly if they are all 
serving site assets IE: images, style sheets, javascripts

However, the application that I run serves over 1 million pages a day and 300k 
in unique users. 

The biggest performance gain I've seen was when I moved caching ( Including 
schema caching ) over to a dedicated memcached server.

I've also moved over my PHP session to memcache VS database sessions and seen a 
significant performance gain.

If you have any other questions feel free to ask and I'll try and advise where 
I can.

On Feb 15, 2012, at 8:28 AM, Andres Montiel, CUA wrote:

 Thanks John. I also see that you're using HAProxy for the cluster. Sticky 
 sessions for CakePHP?
 
 On Thu, Feb 16, 2012 at 12:08 AM, John Hardy john.c.ha...@gmail.com wrote:
 Yes.
 
 I have a cluster of 6 nodes serving my site. 
 
 Screen Shot 2012-02-15 at 8.08.20 AM.png
 
 On Feb 14, 2012, at 5:19 PM, kyutums wrote:
 
 We are currently using CodeIgniter in another project. To handle large
 traffic (we get around 60k pageviews per day), we load balance between
 2 EC2 instances.
 
 Is it possible to load balance using CakePHP as well? Also, would it
 be easy to add another server in the cluster using 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
 
 
 -- 
 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


Using HABTM

2012-02-15 Thread Sean
Hi all,

I am trying to do something that I think is pretty common.

I am working on an auction site and if I had say a auctions table and
a auction_images table. I want to be able to use multiple images with
multiple auctions.

In other words - auction1 be associated with auction_image 1, 2, 3 
auction2 be associated with 1, 2, 3

When I use a $belongsTo relationship from Users to Images it works
fine, but that limits things to haveing specific images directly
linked to image id's (effectively using up the associated images).

I thought that the HABTM direction was the way to go, but am having a
problem with it.  But when I use HABTM, I get an error that the model
images is not associated with the model images. I believe that I have
followed the book.cakephp directions and Josh Benner's directions but
it's not working.

Here are the model's:

 Auction Model:
class Auction extends AppModel {

var $name = 'Auction';

var $actsAs = array('Containable');

var $belongsTo = array(
'Category' = array(
'className'  = 'Category',
'foreignKey' = 'category_id'
),
'Status' = array(
'className'  = 'Status',
'foreignKey' = 'status_id'
),
'Winner' = array(
'className'  = 'User',
'foreignKey' = 'winner_id'
)
);

var $hasMany = array(
'Bidbutler'  = array(
'className'  = 'Bidbutler',
'foreignKey' = 'auction_id',
'limit'  = 10,
'dependent'  = true
),

'Bid' = array(
'className'  = 'Bid',
'foreignKey' = 'auction_id',
'order'  = 'Bid.id DESC',
'limit'  = 10,
'dependent'  = true
),

'Autobid' = array(
'className'  = 'Autobid',
'foreignKey' = 'auction_id',
'limit'  = 10,
'dependent'  = true
)
);

var $hasAndBelongsTo = array(
'AuctionImage'   =
array(
'className'  = 
'AuctionImage',
'joinTable' = 
'auctions_auction_images',
'foreignKey'   = 
'auction_id',
'associationForeignKey' = 
'auction_image_id',
'unique'= 
false,
'limit'= 
'6',
'order'= 
array('order' = 'asc'),
),
);

 AuctionImages Model:

class AuctionImage extends AppModel {

var $name = 'AuctionImage';

var $hasAndBelongsToMany = array(
'Auction' = array(
'className'   = 'Auction',
'joinTable'   = 
'auctions_auction_images',
'foreignKey'= 
'auction_image_id',
'associationForeignKey'  = 'auction_id',
'unique' = false,
'limit'= '6'

)
);

I'm not sure how the controller language is supposed to look but an
example of the auction_image language would be:

$auction = $this-AuctionImage-Auction-read(null, $auction_id);

-- 
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: create duplicate record

2012-02-15 Thread elogic
Thanks, Where do I put it though?

I tried this:

$existing_id = $this-request-data['Ladder']['id'];
$new_record = $this-Ladder-findById($existing_id);
unset($new_record['Ladder']['id']);
$new_record['Ladder']['level'] = $next_round;
$new_record['Ladder']['status'] = 0;
print_r($new_record);
$this-Ladder-create();
$this-Ladder-save($new_record);


Which does create the new record but it isn't saving the changed
values within the $new_record array. It is just saving the same
details as the original.

print_r($new_record); - this is showing the data has been updated but
it isn't being used in the create / save of the new record.

Thanks



On Feb 15, 5:38 pm, Andras Kende and...@kende.com wrote:
 try to add:

 $this-Ladder-create();

 Andras Kende

 On Feb 15, 2012, at 1:12 AM, elogic wrote:







  Thanks,

  This is what I have:

  // GET THE EXISTING RECORD, REMOVE THE ID, UPDATE THE LEVEL AND SAVE
  // --
  $existing_id = $this-request-data['Ladder']['id'];
  $new_record = $this-Ladder-findById($existing_id);
  unset($new_record['Ladder']['id']);
  $new_record['Ladder']['level'] = $next_round;
  $this-Ladder-save($new_record);

  Nothing is saving though?

  Thanks

  On Feb 15, 4:16 pm, Jeremy Burns | Class Outfit
  jeremybu...@classoutfit.com wrote:
  Do a find, remove the 'id' key from the resulting array, change the value 
  of the field/key you want and then save it again. The lack of an id key 
  will force a save rather than an update.

  Jeremy Burns
  Class Outfit

 http://www.classoutfit.com

  On 15 Feb 2012, at 06:04:20, elogic wrote:

  Is there an easy way to create a duplicate record using cakePHP and
  maybe change one field in the duplication while still keeping the
  original?

  Thanks

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp 
  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 
  athttp://groups.google.com/group/cake-php

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 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 
  athttp://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


Using Cakephp 1.3 console with Cakephp 2.0

2012-02-15 Thread damanlovett
I am wondering if it is possible to use the 1.3 console on the same 
computer you have the CakePHP v2.0.0 console running.

I have changed my paths and I'm using the CakePHP v2.0.0 for baking but I 
have a couple of old sites that are running 1.3 and I need to do some 
baking.  Is it possible to tell Cake to run the console from the the 1.3 
folder instead of the v2.0.0 folder.

-- 
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: Using Cakephp 1.3 console with Cakephp 2.0

2012-02-15 Thread jeremyharris
You can by just browsing to the 1.3's console directory and running it from 
there

cd /path/to/1.3app/cake/console 
cake -app /path/to/1.3app bake

All putting it in your path does is make it easy to call cake bake from 
anywhere.

-- 
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: Using HABTM

2012-02-15 Thread Florin Trifu
Hi

I don't know if my understanding is correct, but Auction hasMany
AuctionImages and not HABTM.
You should try to change that hasAndBelongsTo from the Auction model, of
which I've never heard by the way, into hasMany.

As by the error following the pattern model_name_X is not associated with
model_name_X usually appears in this case:

Let's take for example you Image model:

- you use $actsAs = array('Containable')
- then you pass an array following this pattern into a query interrogating
the Image model:

array('contain' = array('Image' [,'model_name']))

Hope it's useful!

Best regards!

On Wed, Feb 15, 2012 at 10:40 PM, Sean sean.rac...@gmail.com wrote:

 Hi all,

 I am trying to do something that I think is pretty common.

 I am working on an auction site and if I had say a auctions table and
 a auction_images table. I want to be able to use multiple images with
 multiple auctions.

 In other words - auction1 be associated with auction_image 1, 2, 3 
 auction2 be associated with 1, 2, 3

 When I use a $belongsTo relationship from Users to Images it works
 fine, but that limits things to haveing specific images directly
 linked to image id's (effectively using up the associated images).

 I thought that the HABTM direction was the way to go, but am having a
 problem with it.  But when I use HABTM, I get an error that the model
 images is not associated with the model images. I believe that I have
 followed the book.cakephp directions and Josh Benner's directions but
 it's not working.

 Here are the model's:

 Auction Model:
class Auction extends AppModel {

var $name = 'Auction';

var $actsAs = array('Containable');

var $belongsTo = array(
'Category' = array(
'className'  = 'Category',
'foreignKey' = 'category_id'
),
'Status' = array(
'className'  = 'Status',
'foreignKey' = 'status_id'
),
'Winner' = array(
'className'  = 'User',
'foreignKey' = 'winner_id'
)
);

var $hasMany = array(
'Bidbutler'  = array(
'className'  = 'Bidbutler',
'foreignKey' = 'auction_id',
'limit'  = 10,
'dependent'  = true
),

'Bid' = array(
'className'  = 'Bid',
'foreignKey' = 'auction_id',
'order'  = 'Bid.id DESC',
'limit'  = 10,
'dependent'  = true
),

'Autobid' = array(
'className'  = 'Autobid',
'foreignKey' = 'auction_id',
'limit'  = 10,
'dependent'  = true
)
);

var $hasAndBelongsTo = array(
'AuctionImage'   =
array(
'className'  =
 'AuctionImage',
'joinTable' =
 'auctions_auction_images',
'foreignKey'   =
 'auction_id',
'associationForeignKey' =
 'auction_image_id',
'unique'=
 false,
'limit'
  = '6',
'order'
  = array('order' = 'asc'),
),
);

 AuctionImages Model:

class AuctionImage extends AppModel {

var $name = 'AuctionImage';

var $hasAndBelongsToMany = array(
'Auction' = array(
'className'   = 'Auction',
'joinTable'   =
 'auctions_auction_images',
'foreignKey'=
 'auction_image_id',
'associationForeignKey'  = 'auction_id',
'unique' = false,
'limit'= '6'

)
);

 I'm not sure how the controller language is supposed to look but an
 example of the auction_image language would be:

 $auction = $this-AuctionImage-Auction-read(null, $auction_id);

 --
 

[ASK] Better way to send email?

2012-02-15 Thread thom
Hello, I need to send Email notification every time new record has
inserted. I just wonder which one is better way (or the best way?) to send
Email via CakePHP. Is it from Controller, or from Model thru afterSave?
Just wonder, since Email Component is made to be inside Controller, but I
heard out there people always give advice : thick Model thin Controller.

Thank you for any response.

-- 
Regards,,,
thom
http://mynameisthom.blogspot.com
http://www.twitter.com/iamthom_
http://id.linkedin.com/in/mastanto

-- 
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: Better way to send email?

2012-02-15 Thread euromark
what version are you using?
in cake2 it is a Lib CakeEmail and can be used from anywhere you
want to


On 15 Feb., 23:39, thom cyber.phanto...@gmail.com wrote:
 Hello, I need to send Email notification every time new record has
 inserted. I just wonder which one is better way (or the best way?) to send
 Email via CakePHP. Is it from Controller, or from Model thru afterSave?
 Just wonder, since Email Component is made to be inside Controller, but I
 heard out there people always give advice : thick Model thin Controller.

 Thank you for any response.

 --
 Regards,,,
 thomhttp://mynameisthom.blogspot.comhttp://www.twitter.com/iamthom_http://id.linkedin.com/in/mastanto

-- 
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: Using Cakephp 1.3 console with Cakephp 2.0

2012-02-15 Thread euromark
I do it the other way around.
Go to the app dir and

app20..\lib\Cake\Console\cake  ...

app13..\cake\console\cake ...



On 15 Feb., 23:17, jeremyharris funeralm...@gmail.com wrote:
 You can by just browsing to the 1.3's console directory and running it from
 there

 cd /path/to/1.3app/cake/console
 cake -app /path/to/1.3app bake

 All putting it in your path does is make it easy to call cake bake from
 anywhere.

-- 
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: Load balance CakePHP between 2 EC2 instances

2012-02-15 Thread Andres Montiel, CUA
Thanks John. These inputs are already a VERY big help. I'll holler again
should I need any clarification. :)


On Thu, Feb 16, 2012 at 3:31 AM, John Hardy john.c.ha...@gmail.com wrote:

 No sticky sessions, through my experience with load balancing my
 particular cakePHP application ( and various others ) I've found that
 sticky sessions does not evenly balance the load across machines,
 particularly if they are all serving site assets IE: images, style sheets,
 javascripts

 However, the application that I run serves over 1 million pages a day and
 300k in unique users.

 The biggest performance gain I've seen was when I moved caching (
 Including schema caching ) over to a dedicated memcached server.

 I've also moved over my PHP session to memcache VS database sessions and
 seen a significant performance gain.

 If you have any other questions feel free to ask and I'll try and advise
 where I can.

 On Feb 15, 2012, at 8:28 AM, Andres Montiel, CUA wrote:

 Thanks John. I also see that you're using HAProxy for the cluster. Sticky
 sessions for CakePHP?

 On Thu, Feb 16, 2012 at 12:08 AM, John Hardy john.c.ha...@gmail.comwrote:

 Yes.

 I have a cluster of 6 nodes serving my site.

 Screen Shot 2012-02-15 at 8.08.20 AM.png

 On Feb 14, 2012, at 5:19 PM, kyutums wrote:

 We are currently using CodeIgniter in another project. To handle large
 traffic (we get around 60k pageviews per day), we load balance between
 2 EC2 instances.

 Is it possible to load balance using CakePHP as well? Also, would it
 be easy to add another server in the cluster using 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



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


-- 
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: Better way to send email?

2012-02-15 Thread thom
On Thu, Feb 16, 2012 at 6:53 AM, euromark dereurom...@googlemail.comwrote:

 what version are you using?
 in cake2 it is a Lib CakeEmail and can be used from anywhere you
 want to



Oops. My mistake, not mentioned the version. I am now still using cakePPH
1.3
And, yeah, I know about CakeEmail in v 2.0 :D Just wonder how is it when in
1.3.. I am still developing with that version,


-- 
Regards,,,
thom
http://mynameisthom.blogspot.com
http://www.twitter.com/iamthom_
http://id.linkedin.com/in/mastanto

-- 
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: Using HABTM

2012-02-15 Thread Sean
Thanks for the reply, Florin.

Auction hasMany AuctionImages is the way that it is currently set. The
problem is that it currently uses up any AuctionImage that is
associated with the Auction. Each image is associated with a
particular auction_id.

What I'm looking for is a way to have a set of images that I then
associate with numerous auctions. That is multiple images with
multiple auctions (e.g. 6 images for a single item type and then
associate them with multiple auctions).

In addition to the structure that I'm attempting in the Models, here
is the current structure of the database tables:

 auctions:
  Column   Type
 1  id  int(11)(AUTO INCREMENT)
 2  title   varchar(255)
 5  description text
 6  category_id int(11)
 
 26 created datetime
 27 modifieddatetime

Keyname  Type Unique  Column
PRIMARY BTREE   Yes id
category_id BTREE   No  category_id

 auction_images:
 1  id  int(8)  UNSIGNED
AUTO_INCREMENT
 2  auction_id  int(11)
 3  image   varchar(255)
 4  order   int(11)
 5  created datetime
 6  modifieddatetime

 Keyname   Type   Unique  Column
 PRIMARY  BTREE Yes id
 auction_id   BTREE No  auction_id


 Join table - auctions_auction_images
 1 id   int(11)  AUTO_INCREMENT
 2 auction_id   int(11)
 3 auction_image_id int(11)
 4 order   int(1)

Keyname TypeUniqueColumn
PRIMARY BTREE   Yes   id
auction_id  BTREE   Noauction_id
auction_image_idBTREE   Noauction_image_id

I hope this help clear up what I am looking for.

Thanks,
Sean

On Feb 15, 5:33 pm, Florin Trifu florin.catalin.tr...@gmail.com
wrote:
 Hi

 I don't know if my understanding is correct, but Auction hasMany
 AuctionImages and not HABTM.
 You should try to change that hasAndBelongsTo from the Auction model, of
 which I've never heard by the way, into hasMany.

 As by the error following the pattern model_name_X is not associated with
 model_name_X usually appears in this case:

 Let's take for example you Image model:

 - you use $actsAs = array('Containable')
 - then you pass an array following this pattern into a query interrogating
 the Image model:

 array('contain' = array('Image' [,'model_name']))

 Hope it's useful!

 Best regards!







 On Wed, Feb 15, 2012 at 10:40 PM, Sean sean.rac...@gmail.com wrote:
  Hi all,

  I am trying to do something that I think is pretty common.

  I am working on an auction site and if I had say a auctions table and
  a auction_images table. I want to be able to use multiple images with
  multiple auctions.

  In other words - auction1 be associated with auction_image 1, 2, 3 
  auction2 be associated with 1, 2, 3

  When I use a $belongsTo relationship from Users to Images it works
  fine, but that limits things to haveing specific images directly
  linked to image id's (effectively using up the associated images).

  I thought that the HABTM direction was the way to go, but am having a
  problem with it.  But when I use HABTM, I get an error that the model
  images is not associated with the model images. I believe that I have
  followed the book.cakephp directions and Josh Benner's directions but
  it's not working.

  Here are the model's:

      Auction Model:
         class Auction extends AppModel {

                 var $name = 'Auction';

                 var $actsAs = array('Containable');

                 var $belongsTo = array(
                         'Category' = array(
                                 'className'  = 'Category',
                                 'foreignKey' = 'category_id'
                         ),
                         'Status' = array(
                                 'className'  = 'Status',
                                 'foreignKey' = 'status_id'
                         ),
                         'Winner' = array(
                                 'className'  = 'User',
                                 'foreignKey' = 'winner_id'
                         )
                 );

                 var $hasMany = array(
                         'Bidbutler'  = array(
                                 'className'  = 'Bidbutler',
                                 'foreignKey' = 'auction_id',
                                 'limit'      = 10,
                                 'dependent'  = true
       

Re: create duplicate record

2012-02-15 Thread elogic
Ignore this, user error.

I had the field in the database setup incorrectly so it would accept
the value I was changing.

Thanks

On Feb 16, 7:38 am, elogic asymo...@elogicmedia.com.au wrote:
 Thanks, Where do I put it though?

 I tried this:

 $existing_id = $this-request-data['Ladder']['id'];
 $new_record = $this-Ladder-findById($existing_id);
 unset($new_record['Ladder']['id']);
 $new_record['Ladder']['level'] = $next_round;
 $new_record['Ladder']['status'] = 0;
 print_r($new_record);
 $this-Ladder-create();
 $this-Ladder-save($new_record);

 Which does create the new record but it isn't saving the changed
 values within the $new_record array. It is just saving the same
 details as the original.

 print_r($new_record); - this is showing the data has been updated but
 it isn't being used in the create / save of the new record.

 Thanks

 On Feb 15, 5:38 pm, Andras Kende and...@kende.com wrote:







  try to add:

  $this-Ladder-create();

  Andras Kende

  On Feb 15, 2012, at 1:12 AM, elogic wrote:

   Thanks,

   This is what I have:

   // GET THE EXISTING RECORD, REMOVE THE ID, UPDATE THE LEVEL AND SAVE
   // --
   $existing_id = $this-request-data['Ladder']['id'];
   $new_record = $this-Ladder-findById($existing_id);
   unset($new_record['Ladder']['id']);
   $new_record['Ladder']['level'] = $next_round;
   $this-Ladder-save($new_record);

   Nothing is saving though?

   Thanks

   On Feb 15, 4:16 pm, Jeremy Burns | Class Outfit
   jeremybu...@classoutfit.com wrote:
   Do a find, remove the 'id' key from the resulting array, change the 
   value of the field/key you want and then save it again. The lack of an 
   id key will force a save rather than an update.

   Jeremy Burns
   Class Outfit

  http://www.classoutfit.com

   On 15 Feb 2012, at 06:04:20, elogic wrote:

   Is there an easy way to create a duplicate record using cakePHP and
   maybe change one field in the duplication while still keeping the
   original?

   Thanks

   --
   Our newest site for the community: CakePHP Video 
   Tutorialshttp://tv.cakephp.org
   Check out the new CakePHP Questions 
   sitehttp://ask.cakephp.organdhelpothers with their CakePHP related 
   questions.

   To unsubscribe from this group, send email to
   cake-php+unsubscr...@googlegroups.com For more options, visit this 
   group athttp://groups.google.com/group/cake-php

   --
   Our newest site for the community: CakePHP Video 
   Tutorialshttp://tv.cakephp.org
   Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp 
   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 
   athttp://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