Too many MySQL processes sleeping for CakePHP 1.2.0.7692 RC3

2008-11-08 Thread dericknwq

Anyone experiencing the same problems? I have upgraded from 1.2 RC2 to
RC3 but reverted back because the MySQL processes (SHOW PROCESSLIST)
kept building up causing MySQL to run out of connections.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Using $javascript->link('somefile', false) in an element doesn't work

2008-05-28 Thread dericknwq

Erm, it seems like the $scripts_for_layout var is populated before the
elements are rendered so it doesn't contain the scripts which you add
it in an element.

My scenario:
/posts/view/123

and in view.ctp:
$this->element('456')

and in 456.ctp:
$javascript->link('somefile', false)

It doesn't work. It does if I link it in view.ctp as per normal
though. Anyone had similar issues or is this meant to be?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Best practice or not for using Email component in the model

2008-05-07 Thread dericknwq

There are times where I seriously feel the need to send an email from
the model like at the afterSave() stage or something. Say each time a
new comment is added to a post, a notification will be sent to
participants depending on certain conditions. It just feels more
correct having those checks and sending of emails in the model.

E.g. Controller:

$this->Model->saveThis($someComment);
if ($this->Model->shouldSendNotification()) {
  $data = $this->Model->getNecessaryData();
  $this->__sendNotificationWithEmailComponent($data);
}

Why not have saveThis() do the work and send the notifications? I do
think that it will be possible to just pass the Email component into
the model but is that technically correct? How did you do yours?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Load balanced web servers with CakePHP

2007-11-28 Thread dericknwq

Woah. I attest for the ease of setting up memcached. I've gotten it
working via Cake within hours. Tested with failing nodes etc. to see
the behaviour. Pretty cool!

Now what I have to do next is to replace my element calls with a new
helper which utilise memcached instead. cache() still writes to the
tmp folder as of now. :(

On Nov 28, 9:32 am, dericknwq <[EMAIL PROTECTED]> wrote:
> @Sean: I would think memcached is faster though both runs through the
> network.
>
> I have got no spare servers at the moment but I could steal 512MB off
> each of the servers running which should be more than enough for the
> cache from what I see now. I'm basing on that the current cache folder
> is just less than 10MB so with memcached I'll probably take like less
> than double the amount?
>
> I have briefly read bout memcached through my usual feeds just lacking
> the chance to try it out. Do not really have much time so the good
> thing is memcached seems relatively easy to setup.
>
> > We've recently moved our sessions from the db over to the memcached
> > cluster too and have had a nice speed boost so you might consider that
> > also.
>
> I'm curious about this, did you have to rewrite/extend the session
> component?
>
> What other nifty tricks could you share about your current setup?
>
> On Nov 28, 12:06 am, bgmill <[EMAIL PROTECTED]> wrote:
>
> > Yes I'm usingmemcacheextensively across a large (cake 1.1) app
> > running on 5 web servers and its been rock solid so far.
>
> > We've recently moved our sessions from the db over to the memcached
> > cluster too and have had a nice speed boost so you might consider that
> > also.
>
> > On Nov 27, 1:19 pm, dericknwq <[EMAIL PROTECTED]> wrote:
>
> > > I have read about it but nope, never consider it yet. Seems like a
> > > pretty good replacement though since it's meant to be a global cache.
> > > How is Cake's support formemcache? You tried it personally?
>
> > > On Nov 27, 7:05 pm, bgmill <[EMAIL PROTECTED]> wrote:
>
> > > > Have you considered using memcached?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Load balanced web servers with CakePHP

2007-11-27 Thread dericknwq

@Sean: I would think memcached is faster though both runs through the
network.

I have got no spare servers at the moment but I could steal 512MB off
each of the servers running which should be more than enough for the
cache from what I see now. I'm basing on that the current cache folder
is just less than 10MB so with memcached I'll probably take like less
than double the amount?

I have briefly read bout memcached through my usual feeds just lacking
the chance to try it out. Do not really have much time so the good
thing is memcached seems relatively easy to setup.

> We've recently moved our sessions from the db over to the memcached
> cluster too and have had a nice speed boost so you might consider that
> also.

I'm curious about this, did you have to rewrite/extend the session
component?

What other nifty tricks could you share about your current setup?

On Nov 28, 12:06 am, bgmill <[EMAIL PROTECTED]> wrote:
> Yes I'm using memcache extensively across a large (cake 1.1) app
> running on 5 web servers and its been rock solid so far.
>
> We've recently moved our sessions from the db over to the memcached
> cluster too and have had a nice speed boost so you might consider that
> also.
>
> On Nov 27, 1:19 pm, dericknwq <[EMAIL PROTECTED]> wrote:
>
> > I have read about it but nope, never consider it yet. Seems like a
> > pretty good replacement though since it's meant to be a global cache.
> > How is Cake's support for memcache? You tried it personally?
>
> > On Nov 27, 7:05 pm, bgmill <[EMAIL PROTECTED]> wrote:
>
> > > Have you considered using memcached?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Load balanced web servers with CakePHP

2007-11-27 Thread dericknwq

I have read about it but nope, never consider it yet. Seems like a
pretty good replacement though since it's meant to be a global cache.
How is Cake's support for memcache? You tried it personally?

On Nov 27, 7:05 pm, bgmill <[EMAIL PROTECTED]> wrote:
> Have you considered using memcached?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Load balanced web servers with CakePHP

2007-11-27 Thread dericknwq

My application is currently running on a load balanced setup but app/
tmp is unique per server. The current problem is that the cache would
be stored on a per server basis which means there is no easy way of
clearing the cache. I am thinking of mounting the cache folder on the
web servers to a common NFS server so multiple web servers share the
same cache folder. Possibly could have the whole temp directory
"shared" by all web servers but not sure if it is feasible.

Anyone here running CakePHP on a load balanced setup as well? Other
than my cache issue, I would like to know about your setup! :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Changes to SecurityComponent - every form I submit gets blackholed

2007-05-04 Thread dericknwq

Marcus, one of them is the token key as shown on the name attribute
while the other is a token to verify that all fields from your form
are receive on the controller end.

On May 4, 2:37 pm, "Marcus T. Jaschen" <[EMAIL PROTECTED]> wrote:
> dericknwq wrote:
> > I remember asking PhpNut about this and he says it was for security.
> > Right now, in the startup() of the Security component __validatePost
> > is called for each request that is POSTed. And __validatePost requires
> > a Token in your POST, so I presume that's that.
>
> >https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controlle...
> >https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controlle...
>
> In my form are three Tokens defined, with two different hashes:
>
> 1st one after the created form tag (the form and all form elements were
> created with the FormHelper):
>
>  action="/admin/cms_articles/edit/25">
>
> 
>
>  value="0d28260766d81b2d239f9473a89f489b04a570a2"
> id="CmsArticleEditFormToken1827120349" />
>
> 
>
> Now some standard form fields are following:
>
>  id="CmsArticleId" />
>  id="CmsArticleUserId" />
> (... and some more fields)
>
> The second token starts before the submit button, the third comes
> directly before the submit button:
>
> 
>
>  value="0fa3b9736b2b416d355cad3f384fabf64b2e2018"
> id="TokenFields1379082255" />
>
> 
>
> 
>
> 
>
>  value="0fa3b9736b2b416d355cad3f384fabf64b2e2018"
> id="TokenFields1379082255" />
>
> 
>
> 
>
> 
>
> Any ideas why three Tokens are generated and why two of them have
> different hashes?
>
> Marcus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Changes to SecurityComponent - every form I submit gets blackholed

2007-05-03 Thread dericknwq

I remember asking PhpNut about this and he says it was for security.
Right now, in the startup() of the Security component __validatePost
is called for each request that is POSTed. And __validatePost requires
a Token in your POST, so I presume that's that.

https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controller/components/security.php?rev=4972#L142
https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controller/components/security.php?rev=4972#L422

On May 3, 11:25 pm, "Marcus T. Jaschen" <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> in the last days the SecurityComponent was refactored (rev 4972)
>
> After updating to the latest SVN version of CakePHP every Form I submit
> (AJAX oder classic POST-Request) gets blackholed by the SecurityComponent.
>
> I've inlcuded the SecurityComponent in the controllers with
>
> var $components = array('Security', 'RequestHandler', ...);
>
> There are no settings in beforeFilter callback like
>
> $this->Security->requirePost('action1', 'action2') or
> $this->Security->requireAuth('action1', 'action2'),
>
> I just inlucded SecurityComponent.
>
> Can anyone reproduce this? How can I solve this issue?
>
> Marcus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: where to change or add 'This field cannot be left blank' such validate msg?

2007-04-21 Thread dericknwq

In your $validate array, do something like

$validate = array(
  'fieldname' => array(
'allowEmpty' => false,
'message' => 'Boo, enter something yea?',
'rule' => 'blank'
  )
);

On Apr 22, 10:46 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> where to change or add 'This field cannot be left blank' such validate
> msg?
>
> I am using .1.2xx ,it seems like nowhere to edit this kind msg.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Passing arguments to a nested element

2007-04-21 Thread dericknwq

If I'm not wrong, your viewVars are always passed to the element. So
in fact once you've set the vars using $this->set() on your
controller, all the elements could receive those variables as well
even if you don't specifically provide the params when calling
renderElement.

That said, I may have misunderstood your question. :p

On Apr 22, 10:03 am, Gonza <[EMAIL PROTECTED]> wrote:
> Hi Mariano,
>
> Gracias. Like you said, it's not the most elegant solution but it'll
> probably work.
>
> Thanks!
> Gonzalo
>
> On Apr 21, 8:55 pm, "Mariano Iglesias" <[EMAIL PROTECTED]>
> wrote:
>
> > You can do it through a quick hack, though it is not very elegant. Let's say
> > that on your view you have:
>
> > renderElement('element1', array('arg1' => 'Hello', 'arg2'
> > => 'World')); ?>
>
> > And element1 includes element2. Element2 looks like:
>
> > 
>
> > Then the hack is to make element1 look like:
>
> > 
> > $loaded = am(array_keys($this->viewVars), array_keys($this->loaded));
> > $args = array_diff_key($___dataForView, array_flip($loaded));
>
> > echo $this->renderElement('element2', $args);
>
> > ?>
>
> > -MI
>
> > ---
>
> > Remember, smart coders answer ten questions for every question they ask.
> > So be smart, be cool, and share your knowledge.
>
> > BAKE ON!
>
> > blog:http://www.MarianoIglesias.com.ar
>
> > 
> > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
> > de Gonzalo Servat
> > Enviado el: Sábado, 21 de Abril de 2007 08:35 p.m.
> > Para: cake-php@googlegroups.com
> > Asunto: Re: Passing arguments to a nested element
>
> > .. but not quite the solution I was looking for. What I'm trying to avoid is
> > having to specifically write each and every variable in either method. I was
> > hoping for a way to grab them all and send the arguments to the next
> > renderElement call. Maybe I understood how to use compact? I'd really
> > appreciate an example.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Why does Cake generate these redundant unnecessary queries?

2007-04-09 Thread dericknwq

This was my point when I posted
http://groups.google.com/group/cake-php/browse_thread/thread/b73a9a23b593c837/f0a4ae54e8892e45?hl=en#f0a4ae54e8892e45

Anyways, I don't suppose you will need a level 2 recursive call based
on the Model you've shown. But http://bakery.cakephp.org/articles/view/185
should help greatly. :)

On Apr 10, 12:54 am, "barduck" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was looking at my SQL debug logs and seeing a lot of redundant
> unnecessary queries which I don't think should be there at all. I am
> using the nightly build of 1.2 from couple of days ago but I was
> seeing this with 1.2 for quite a while.
>
> So I created a very basic scenario and this is still reproducing, just
> two DB tables and two cake models:
>
> class Category extends AppModel
> {
> var $name = 'Category';
>
> }
>
> class Product extends AppModel
> {
> var $name = 'Product';
>
> var $belongsTo = array('Category');
>
> var $recursive = 2;
>
> }
>
> In my products controller, I want to get all products:
>
> $products = $this->Product->findAll();
>
> And this is what I see in the SQL log:
>
> 1   DESC `products` 3   3   5
> 2   DESC `categories`   2   2   5
> 3   SELECT `Product`.`id`, `Product`.`name`, `Product`.`category_id`,
> `Category`.`id`, `Category`.` name` FROM `products` AS `Product` LEFT
> JOIN `categories` AS `Category` ON (`Product`.`category_id` =
> `Category`.`id`) WHERE 1 = 112  12  1
> 4   SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 11   1   1
> 5   SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 11   1   0
> 6   SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 11   1   0
> 7   SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 11   1   0
> 8   SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 31   1   0
> 9   SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 31   1   1
> 10  SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 31   1   0
> 11  SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 31   1   3
> 12  SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 31   1   1
> 13  SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 31   1   1
> 14  SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 21   1   1
> 15  SELECT `Category`.`id`, `Category`.` name` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 21   1   0
>
> What are all the SELECT queries from categories table doing there?
> They are already included in the main query with the LEFT JOIN and why
> is there a separate query for each product row even if the same
> category was already fetched?
>
> This is just a sample DB, in my real scenario with many more
> associations, a findAll() query generates over 1000 redundant queries
> which takes some time to execute.
>
> Can anyone shed some light on this?
>
> Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Scary associations with recursive calls

2007-04-09 Thread dericknwq

Yes exactly. I tried the expects() and it works like a charm. When
recursive calls get too deep, the replicated queries get really scary.
On top of that half the time we will not be using most of the data
returned as well. It will be really sweet if there is a way to not
just specify the Model required but also the fields required.

My main question was with such problems, will you guys prefer to not
add any association on the Model itself. But use bindModel in your
Model and specify the fields required to retrieve the data. This way,
you will not be returned with huge amount of data which you do not
actually need. It will be sweet if somehow expects() can accept the
keys "conditions" and "fields" as well.

The another question I was trying to bring up is that in my example,
Application belongsTo User and User hasOne Profile. Will you guys
actually do things like:

bindModel(array(
'belongsTo/hasOne' => array(
'Profile' => array(
'foreignKey' => 'user_id'
)
)
)

This will "link" Application direct to the Profile using the user_id
field and thus, cake will then LEFT JOIN the Profile instead of making
separate queries. Of course, the no longer forces the actual
relationship of the models. What say you? Good or Bad practice?

On Apr 9, 7:50 pm, Felix Geisendörfer <[EMAIL PROTECTED]> wrote:
> > I've used expects() and in my opinion, should become a core feature of
> > CakePHP. It feels a lot more natural than the bind and unbinding of
> > associations. It's succinct. And because it's built on top of the bind/
> > unbind approach, you can still use it if necessary.
>
> +1. I could not imagine dealing with big databases without some kind of
> Model::expects or unbindAllExcept function. It's very useful indeed.
>
> -- Felix
> --http://www.thinkingphp.orghttp://www.fg-webdesign.de
>
> jonathan.snook wrote:
> > On Apr 9, 12:01 am, "Mariano Iglesias" <[EMAIL PROTECTED]>
> > wrote:
>
> >> This sounds like a scream for help, and expects() is up to the challenge ;)
>
> >>http://bakery.cakephp.org/articles/view/185
>
> > I've used expects() and in my opinion, should become a core feature of
> > CakePHP. It feels a lot more natural than the bind and unbinding of
> > associations. It's succinct. And because it's built on top of the bind/
> > unbind approach, you can still use it if necessary.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---