Re: cakeDC Tag Plugin Delete issue

2010-07-13 Thread abocanegra
I solved it, You can check out the code on my blog
http://www.whatartist.com/blog/2010/07/making-cakedc-tags-plugin-delete-by-model-only/

On Jul 8, 4:35 am, abocanegra  wrote:
> I have been enjoying the Tag Plugin by CakeDC. However, I am having an
> issue when it is utilized across multiple models (i.e Photo, Design,
> Video). When I delete an entry with tags in say Photos it deletes
> based off of foreign_key which is the ID of photos. However, if I also
> have the same ID in Designs or Videos it also deletes those tags. I am
> aware of the options in the actsas function in the model. Still i am
> unable to figure out how to delete based on foreign_key and model =>
> Design ( or the appropriate model in any case ).
>
> Has anybody had experience with this?
>
> my model currently is just using the default:
>
>         var $actsAs = array(
>         'Tags.Taggable');
>
> The additional options on their site are:
>
> var $actsAs = array(
>         'Tags.Taggable' => array(
>                 'separator' => '',
>                 'field' => 'tags',
>                 'tagAlias' => 'Tag',
>                 'tagClass' => 'Tags.Tag',
>                 'taggedClass' => 'Tags.Tagged',
>                 'foreignKey' => 'foreign_key',
>                 'associationForeignKey' => 'tag_id',
>                 'automaticTagging' => true,
>                 'unsetInAfterFind' => false,
>                 'resetBinding' => false,
>         )
> );
>
> This is the last obstacle I have before launching my new site, it
> seems small, but it is quite frustrating.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


function problem in controller

2010-07-13 Thread Master Ram
Hi. to all

in my controller i am using one function.

function text() {

;;; 1000 lines of code
;;;
}

function add() {

//Here i want same code. is having in text function. it is possible to
call text() here.

// i want to reduce the code.

}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: load configure variables from DB.

2010-07-13 Thread Shashidhar
the second implementation could work for me. Thanks :)

Regards,
Shashidhar.G

On Jul 14, 2:02 am, Sam  wrote:
> Actually, this implementation is 
> better:http://dsi.vozibrale.com/articles/view/simple-db-based-configuration-...
>
> On Jul 13, 1:45 pm, Shashidhar  wrote:
>
> > Hello,
>
> > In my project we need to store come configure in the DB, and these
> > need to variables needs to be accessed though out the files. I have
> > been trying to figure a way to do this, by googling around. I keep
> > getting the answer as to have in the bootstrap.php, but no examples.
> > Can anyone suggest me how can load these variables stored in the DB
> > and be available through out my modes, controllers and views. If the
> > answer is still to put it in the bootstrap.php please provide with
> > examples, as I am unable to find any good examples for bootstrap.php
> > file.
>
> > Thanks & Regards,
> > Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: HABTM Containable find('all') question

2010-07-13 Thread bradmaxs
Hey Paul,

Just wanted to update you.  I could never get it working.  Tried the
examples above and couldn't come up with anything.

Finally got back to it today and just added an if clause to the view
to filter out result that had that parameter.  Not sure if it is the
best but it is working well.

Thanks for all of your help.  I did learn a lot along the way so it
wasn't in vein I assure you.

Brad

On May 31, 3:33 am, WebbedIT  wrote:
> Your double join on the same table is fine, I just didn't notice it.
>
> Can you try this instead?
>
> SELECT DISTINCT User.id, User.username FROM users AS User
> LEFT JOIN friends AS Friend ON (User.id = Friend.user_id AND
> Friend.approved IN(0,1))
> LEFT JOIN friends AS Admirer ON (User.id = Admirer.friend_id AND
> Admirer.approved IN(0,1))
>
> Does this give the desired results where the Friend count is the
> amount of records where friends.user_id matches the current user and
> the Admirer count is the number of friends where friends.friend_id
> matches the current users.
>
> If this works and pulls the data you are sure it should pull then we
> simply need to force some joins in Cake using:
>
> http://book.cakephp.org/view/86/Creating-and-Destroying-Associations-...
>
> or
>
> http://book.cakephp.org/view/872/Joining-tables
>
> HTH
>
> Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Matt Curry Asset Helper

2010-07-13 Thread Dave Maharaj
Has anyone got this to work for 1.3.x?

 

I have it on my older 1.2.x sites but now I am upgrading and I cant get it
to work at all. White screen of death.

 

Tried 

 

Either

 

echo $this->Html->css(array( 'styles' , 'typography' ));



echo $html->css( array( 'styles' , 'typography' ), null, null, false );

 

with a combination of 

 

echo $asset->scripts_for_layout();

 

or

 

echo $this->Asset->scripts_for_layout();?>

 

but nothing works.

 

Anyone been successful?

 

 

 

Thanks

 

Dave

 

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Last.FM API, DataSource

2010-07-13 Thread Alexandru Ciobanu

 On 7/12/2010 1:46 PM, Linuus wrote:

Hi!

I found this today: http://github.com/m3nt0r/last.fm-datasource-for-cakephp
and wanted to try it out. I'm very new to CakePHP.

I just can't get this datasource to work. I keep getting this error:
"Fatal error: Call to undefined method HttpSocket::buildUri() in /
Applications/MAMP/htdocs/app/models/datasources/lastfm_source.php on
line 573"


I think you're trying this on CakePHP 1.3.x.

buildUri in 1.3.x has an _ (underscore) in front to denote it's 
protected,  so the line 573 should read $sock->_buildUri.


Open up cake/libs/http_socket.php for details.

Other changes might be needed too, I haven't read the entire Last.FM class.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Hello World JS Helper example

2010-07-13 Thread sanedevil
Cricket, Fredflint,
Thanks for the info. Really helps. as things turn out, i got the
example running myself :) but the article that Fred mentioned is
really valuable! thanks again!

On Jul 12, 11:00 pm, "fredfl...@gmail.com" 
wrote:
> I found this article about CakePHP and AJAX via 
> google:http://www.reversefolds.com/articles/show/ajax
>
> I was able to get this running locally following the instructions on
> the blog.
>
> On Jul 12, 2:42 pm, sanedevil  wrote:
>
> > Hi all,
> > I have started to experiment with JS Helper and was very hopeful that
> > the Cake framework will help me avoid a lot of javascript learning via
> > its API. so far i have been struggling (spent the entire weekend! )
> > gettin a simple hello world example to run :(
>
> > Can someone pls share a simple example? I'd appreciate if it has
> > things like
> > . Which js library to use and how to include it in my View?
> > . The series of steps needed to get the example running..
>
> > million thanks in adv!
> > KS

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: comments rate system, help

2010-07-13 Thread Vinicius Núñez
I'm going to try!
thanks!

On 13 jul, 16:08, emptywalls  wrote:
> I think you're looking for the automagic Created and Modified fields
>
> http://book.cakephp.org/view/1015/created-and-modified
>
> Cake will automatically track created/modified if you add these fields
> to your table. Hope this is what you wanted!
>
> On Jul 13, 8:39 am, Vinicius Núñez  wrote:
>
> > I'm doing a rate comments system, and I don't know how to save the
> > dates in the data base. How you can see, I pass an id to the function,
> > which I realize to use to save on the table comments_rate
>
> > comments (id, comment)
> > comments_rate (id, comment_id, rate)
>
> > $html->link('comments_rate', array('controller' => 'comments',
> > 'action' => 'rate_comment', 'id' => $comment_id));
>
> > function rate_comment(id) {
> >  // CODE
>
> > }
>
> > thanks!!!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: load configure variables from DB.

2010-07-13 Thread Sam
Actually, this implementation is better:
http://dsi.vozibrale.com/articles/view/simple-db-based-configuration-for-cakephp-apps

On Jul 13, 1:45 pm, Shashidhar  wrote:
> Hello,
>
> In my project we need to store come configure in the DB, and these
> need to variables needs to be accessed though out the files. I have
> been trying to figure a way to do this, by googling around. I keep
> getting the answer as to have in the bootstrap.php, but no examples.
> Can anyone suggest me how can load these variables stored in the DB
> and be available through out my modes, controllers and views. If the
> answer is still to put it in the bootstrap.php please provide with
> examples, as I am unable to find any good examples for bootstrap.php
> file.
>
> Thanks & Regards,
> Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: load configure variables from DB.

2010-07-13 Thread Sam
Behold, Google Search:
http://bakery.cakephp.org/articles/view/simply-storing-config-values-in-the-db


variables can be accessed throughout the App via Configure::read

On Jul 13, 1:45 pm, Shashidhar  wrote:
> Hello,
>
> In my project we need to store come configure in the DB, and these
> need to variables needs to be accessed though out the files. I have
> been trying to figure a way to do this, by googling around. I keep
> getting the answer as to have in the bootstrap.php, but no examples.
> Can anyone suggest me how can load these variables stored in the DB
> and be available through out my modes, controllers and views. If the
> answer is still to put it in the bootstrap.php please provide with
> examples, as I am unable to find any good examples for bootstrap.php
> file.
>
> Thanks & Regards,
> Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


load configure variables from DB.

2010-07-13 Thread Shashidhar
Hello,

In my project we need to store come configure in the DB, and these
need to variables needs to be accessed though out the files. I have
been trying to figure a way to do this, by googling around. I keep
getting the answer as to have in the bootstrap.php, but no examples.
Can anyone suggest me how can load these variables stored in the DB
and be available through out my modes, controllers and views. If the
answer is still to put it in the bootstrap.php please provide with
examples, as I am unable to find any good examples for bootstrap.php
file.


Thanks & Regards,
Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: comments rate system, help

2010-07-13 Thread emptywalls
I think you're looking for the automagic Created and Modified fields

http://book.cakephp.org/view/1015/created-and-modified

Cake will automatically track created/modified if you add these fields
to your table. Hope this is what you wanted!

On Jul 13, 8:39 am, Vinicius Núñez  wrote:
> I'm doing a rate comments system, and I don't know how to save the
> dates in the data base. How you can see, I pass an id to the function,
> which I realize to use to save on the table comments_rate
>
> comments (id, comment)
> comments_rate (id, comment_id, rate)
>
> $html->link('comments_rate', array('controller' => 'comments',
> 'action' => 'rate_comment', 'id' => $comment_id));
>
> function rate_comment(id) {
>  // CODE
>
> }
>
> thanks!!!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Validation problem

2010-07-13 Thread Felix Fennell
Removing the /i doesn't do anything unfortunately - I read the
handbook page too and thought it should work.

They use this to check for any string using alphanumeric characters +
dashes + underscores;

[0-9a-zA-Z_-]

So I would have though that using [a-zA-Z] would work for just upper
and lowercase letters.

Just so I'm not doing anything stupid, everytime I update the
validation in the model and upload it, I then delete what ever files
are in the /app/tmp/cache/models directory - is there anything else I
need to do.

Felix.

On 13 July 2010 19:37, McBuck DGAF  wrote:
> I thought the "i" at the end of the rule I suggested would make it
> case insensitive, as described in the manual. (Like I said, regex is
> not my thing, I am still learning there . . .)  Anyway, try removing
> the "i" from the end of the last rule you suggested (ie, '/^[a-zA-Z]
> $/') and see if that works.
>
> On Jul 13, 1:36 pm, Felix  wrote:
>> OK, that validation rule works, kinda.
>>
>> If I remove the validation for the company name (temporarily) the rest
>> of the form validation works, with one exception.
>>
>> The new regex doesn't allow for upper case letters, only lower case.
>>
>> I tried changing it from; '/^[a-z]$/i'
>>
>> to: '/^[a-z][A-Z]$/i' --didn't work
>>
>> to: '/^[a-zA-Z]$/i' --didn't work
>>
>> I think there's something basic I'm missing here!
>>
>> As for the company name that still gives the same errors as before.
>>
>> Thanks for your help thus far, Felix.
>>
>> On Jul 13, 3:13 pm, McBuck DGAF  wrote:
>>
>> > Sorry, I wasn't looking at the regex itself, I was just looking at the
>> > way you implemented it (and we have not addressed your 'company_name'
>> > issue at all, but the solution here should be readily adaptable to
>> > that).
>>
>> > I am no regex expert, but wouldn't the following get you what you
>> > want?:
>>
>> > 'rule' => '/^[a-z]$/i',
>>
>> >  (the regex must be delimited by "/", which is probably the source of
>> > your current error)
>>
>> > On Jul 12, 7:18 pm, Felix  wrote:
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Validation problem

2010-07-13 Thread McBuck DGAF
I thought the "i" at the end of the rule I suggested would make it
case insensitive, as described in the manual. (Like I said, regex is
not my thing, I am still learning there . . .)  Anyway, try removing
the "i" from the end of the last rule you suggested (ie, '/^[a-zA-Z]
$/') and see if that works.

On Jul 13, 1:36 pm, Felix  wrote:
> OK, that validation rule works, kinda.
>
> If I remove the validation for the company name (temporarily) the rest
> of the form validation works, with one exception.
>
> The new regex doesn't allow for upper case letters, only lower case.
>
> I tried changing it from; '/^[a-z]$/i'
>
> to: '/^[a-z][A-Z]$/i' --didn't work
>
> to: '/^[a-zA-Z]$/i' --didn't work
>
> I think there's something basic I'm missing here!
>
> As for the company name that still gives the same errors as before.
>
> Thanks for your help thus far, Felix.
>
> On Jul 13, 3:13 pm, McBuck DGAF  wrote:
>
> > Sorry, I wasn't looking at the regex itself, I was just looking at the
> > way you implemented it (and we have not addressed your 'company_name'
> > issue at all, but the solution here should be readily adaptable to
> > that).
>
> > I am no regex expert, but wouldn't the following get you what you
> > want?:
>
> > 'rule' => '/^[a-z]$/i',
>
> >  (the regex must be delimited by "/", which is probably the source of
> > your current error)
>
> > On Jul 12, 7:18 pm, Felix  wrote:

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Validation problem

2010-07-13 Thread Felix
OK, that validation rule works, kinda.

If I remove the validation for the company name (temporarily) the rest
of the form validation works, with one exception.

The new regex doesn't allow for upper case letters, only lower case.

I tried changing it from; '/^[a-z]$/i'

to: '/^[a-z][A-Z]$/i' --didn't work

to: '/^[a-zA-Z]$/i' --didn't work

I think there's something basic I'm missing here!

As for the company name that still gives the same errors as before.

Thanks for your help thus far, Felix.

On Jul 13, 3:13 pm, McBuck DGAF  wrote:
> Sorry, I wasn't looking at the regex itself, I was just looking at the
> way you implemented it (and we have not addressed your 'company_name'
> issue at all, but the solution here should be readily adaptable to
> that).
>
> I am no regex expert, but wouldn't the following get you what you
> want?:
>
> 'rule' => '/^[a-z]$/i',
>
>  (the regex must be delimited by "/", which is probably the source of
> your current error)
>
> On Jul 12, 7:18 pm, Felix  wrote:

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Wrong result with sql query

2010-07-13 Thread Zaky Katalan-Ezra
show some data, error messages...

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: cookie value not returned properly

2010-07-13 Thread yolandapadilla
Wahoo! I finally figured it out.

My problem was caused by Suhosin security patch for PHP that is
installed on my server.

Thanks to another member of this group, I fixed it.  The solution is
here:

"About Security:cipher and Suhosin patch"

http://groups.google.com/group/cake-php/browse_thread/thread/7e6cda2e03a7c54/b685c58394d86f50?lnk=gst&q=decrypt+cookie#b685c58394d86f50

Hope this saves someone else some grief.

On Jul 9, 11:04 am, yolandapadilla  wrote:
> additional testing and new info:
>
> the problem is that cookie value is being encrypted but when
> we call cookie.read the decrypt function thinks the value is not
> encrypted and is not decrypting the value
>
> If I do a cookie.write with $encrypt = false it works but I really
> don't
> want release an app with unencrypted cookies
>
> anyone seen this bug in cake?  anyone have a workaround?
>
> On Jul 8, 11:16 am, yolandapadilla  wrote:
>
>
>
> > I am having a problem with the cookie value not being returned
> > properly.
>
> > I am trying to move a functioning cake app to a new server. I am
> > running version 1.2 of cake. I have gone through all the discussions I
> > can find about installation, config issues and moving to a new server
> > and cannot figure this out.
>
> > The app works fine on the old server but on the new server I am having
> > problems retrieving proper cookie values. I do a var_dump on the
> > cookie after I set the value with a 3 char string. The value is
> > fine.
>
> > I then call redirect to move to a new page. After the redirect when I
> > do a var_dump on the cookie, the value I set is still a 3 char string
> > but the chars are non-ascii values.
>
> > It looks to me like either the value failed to decrypt, or that the
> > value failed to be loaded properly.
> > The keys are fine and the string size is fine.
>
> > Thanks for any insight

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: CakePHP 1.3 Form Samples with default value

2010-07-13 Thread euromark
well, thats how its not supposed to be done
default values should not be hardcoded in the form helper inputs.
if you post the form and some errors are to be corrected by the user
the same hardcoded defaults will populate the fields deleting the
previous made changes. and thats not ok!

use the controller to pass defaults


On 13 Jul., 15:58, Azril Nazli  wrote:
> Might be useful for somebody, here's the sample
>
> http://azrilnazli.blogspot.com/2010/07/cakephp-13-form-samples-with-d...
>
> Pastebin :http://pastebin.com/MAekWJCt
>
> in the controller just debug the inconing value, enjoy
>
> Azril Nazli
> Putrajaya, Malaysia

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to handle Jaywalking - parsing a comma-delimited value in field and do lookups (1,4,5,6...)

2010-07-13 Thread Snaky Love
Hi cricket,

thanks for the beforeSave / afterSave pointer, that would be a good
place for syncing code.

You are right, of course the only right thing to do would be to change
the design of the database, but I am just "on top" of another app here
and I have no chance pushing any changes to the main devs.

However, thank you very much for your attention!

Any other ideas?

Snaky

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Wrong result with sql query

2010-07-13 Thread deepc
I have a sql query that works when i run it in phpmyadmin:

$result = $this->ImportBackup->query("DELETE t1 FROM import_backups
t1, backups t2 WHERE t1.name=t2.name AND t1.drive_id=t2.drive_id;");

This line should delete every record, where name and drive_id are
identival.
It works as long as the drive_id is 0 but not when it is 1 or 2
(drive_id is int)

Can anyone help me?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Too many SQL queries!!

2010-07-13 Thread Alex Bovey
On Tue, Jul 13, 2010 at 12:24 PM, Mike Karthauser
wrote:


> refining by writing custom queries can be useful but having found an issue
> recently where repeated custom queries were stealing memory and not being
> cleared by garbage collection, i'd be a bit wary of this as a solution.
>
> if you do have issues with lots of queries, then you might also be worth
> looking at view/ object caching if they are having performance issues on
> your application.
>
> you'd also be worth moving up to a more recent version of cake1.2 as the
> recent code releases are more optimised than the version you are using.
>
> mikek
>
>
Cheers Mike - I will give that a go in the first instance  - might even go
to 1.3.

Interesting what you say about custom queries.

I definitely need to add some more caching but I thought there might be a
quick fix reducing the number of queries first.

Cheers,

Alex

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: http://www.minijobz.com/signup.php?REF=ZGlsaXBfaXQwMDdAeWFob28uY29t

2010-07-13 Thread Nectom
Don't spam the group.

Dave

On 13 July 2010 17:38, Dilip Godhani  wrote:

> http://www.minijobz.com/signup.php?REF=ZGlsaXBfaXQwMDdAeWFob28uY29t
>
>  Check out the new CakePHP Questions site http://cakeqs.org and help
> others with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


http://www.minijobz.com/signup.php?REF=ZGlsaXBfaXQwMDdAeWFob28uY29t

2010-07-13 Thread Dilip Godhani
http://www.minijobz.com/signup.php?REF=ZGlsaXBfaXQwMDdAeWFob28uY29t

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Cakephp and XAMPP installation nightmare, Can't get cake to understand root

2010-07-13 Thread Dinesh Suryakumar
Walther - Css was rendered as expected

I will actually try the blog tutorial first as all you suggested, will post
again if XAMPP still gives me trouble..
Thanx


On Tue, Jul 13, 2010 at 3:48 AM, Tomfox Wiranata
wrote:

> http://book.cakephp.org/view/1528/Blog
>
> do it step by step..its the perfect way to understand cake..
>
> On 12 Jul., 01:20, Dinu464  wrote:
> > 1) XAMPP 1.7.3 setup and workinghttp://localhost/xampp/-> success
> > 2) Unpacked cake1.3.2, installed under XAMPP -> htdocs -> cake1.3.2
> > (folder)
> > Checked setuphttp://localhost/cake1.3.2/-> success
> >
> > Your tmp directory is writable.
> > The FileEngine is being used for caching. To change the config edit
> > APP/config/core.php
> > Your database configuration file is present.
> > Cake is able to connect to the database.
> >
> > 3) Trying to Implement IBM tutorial Part1
> >
> > Created MySQL tabel 'Users'
> > under cake1.3.2\app\models, created user.php
> > under cake1.3.2\app\controllers, created users_controller.php, with
> > action registration
> > under cake1.3.2\app\view\users, created registration.ctp
> >
> > 4) nowhttp://localhost/cake1.3.2/app/views/users/registeration
> >
> > throws an err
> >
> > Error: ViewsController could not be found.
> > Error: Create the class ViewsController below in file: app\controllers
> > \views_controller.php
> >  > class ViewsController extends AppController {
> >
> > var $name = 'Views';}
> >
> > ?>
> >
> > This is where I am stuck for a week now, can’t get passed this screen,
> > tried several solutions but still cant get this to work..really
> > frustrated. please help!
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Problems with cookies

2010-07-13 Thread Nabil Alsharif
Code and Context are required for assistance.

On Tue, Jul 13, 2010 at 3:07 AM, Iancu Dragos  wrote:
> Hi,
>
> I have a problem using cookies in cakephp 1.3.2
>
> When i write a new cookie it works but it gives me this error:
> Warning (2): srand() expects parameter 1 to be long, string given
> [CORE/cake/libs/security.php, line 177]
>
> When i`m trying to read the cookie it returns me something like that:
> array(1) { ["�Y�� d...@i"]=>  string(40) "ٟ� �`d�y��^PԱ�:
> �o NP ��5��j�$ �S" }
>
> Thanks.
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How to handle Jaywalking - parsing a comma-delimited value in field and do lookups (1,4,5,6...)

2010-07-13 Thread cricket
On Tue, Jul 13, 2010 at 4:57 AM, Snaky Love  wrote:
> Hi,
>
> I have an "interesting" problem here - in a given mysql database
> scheme some sql wizard used comma-separated values in a text-field and
> with that values lookups have to be done. The data itself is simple
> numbers like 1,34,25,66,78,134 and so on. So what I have is something
> like this:
>
> id | username | groups         | more...
> -
> 1 | name        | 1,23,4,55,6  | ...
> 2 | name2      | 3,2,4,5        | ...
>
> The groups string can be very long. there is also a table "groups"
> with "id, name", as expected.
>
> Yes, this is bad design. No, I can not immediately change the design,
> I will try to, but atm I have to handle the situation as it is.
>
> Of course normally this would be solved with an intersection table and
> a many-to-many relation. For anybody interested: there is a book by
> Bill Karwin called "SQL Antipatterns" - he names the described design
> Jaywalking and it is the first antipattern in the book. I was
> surprised to find it in real life
>
> So my question is: how to handle this with cakephp? I really would
> like to use cake to bake a nice management interface on top of that
> tables, but currently I do not know how to go on with that jaywalking
> antipattern in my way.
>
> My first idea was to create my own intersection table - but the
> process of [re-]converting data forth and back does only work in a
> static environment - but the data is heavily used and so
> transformations of tabledata would be neccassery on every request to
> mirror the live situation... so I am looking for a good way to
> implement some kind of layer that would translate this filed for
> cakephp into an intersaection table so that I can use cake models -
> maybe a kind of datasource? Will this work?
>
> What do you think? How to handle this?


Run, don't walk!

heh. Well, off the top of my head, I think you could add some
beforeSave/afterSave logic to keep things synced. Say you provide a
$data array with all the Group info correctly formatted for Cake. When
you save, the data for the Group join is also saved. Then, in the
afterSave callback, your code might fetch all Group.id for this User,
and, separately, the CSV string for this silly User.groups column.
Explode the latter into its own tmp array, sort both sets of data, and
then either add or remove values from the join table or the CSV list
and re-save.

Something like that, anyway. This assumes that you can create your own
join table and the association is set up.

But get rid of that User.groups column as soon as possible. If you can
create your own table, why can't you change the User table? If some
other part of the app is depending on User.groups being a string like
this, then you should address that first to make it more Cake-like, if
possible.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


comments rate system, help

2010-07-13 Thread Vinicius Núñez
I'm doing a rate comments system, and I don't know how to save the
dates in the data base. How you can see, I pass an id to the function,
which I realize to use to save on the table comments_rate

comments (id, comment)
comments_rate (id, comment_id, rate)

$html->link('comments_rate', array('controller' => 'comments',
'action' => 'rate_comment', 'id' => $comment_id));

function rate_comment(id) {
 // CODE
}

thanks!!!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: saveAll changing $this->data

2010-07-13 Thread Shaz
Oo interesting - it's removed 5 from 'asked' ad added it onto saving
and confusion. Post up the $this->save() code so we can see whats
going on.

On 13 July, 12:01, tersmitten  wrote:
> I'm trying to save my $this->data which is (already) a correct array.
> But when I do and look at my queries it looks like saveAll has changed
> my array. Why?
>
> Original array:
> Array
> (
>     [Score] => Array
>         (
>             [questionnaire_id] => 1
>             [asked] => 6
>             [saving] => 0.857142857142857
>             [confusion] => 0.123350661145302
>         )
> )
>
> Sql queries:
>
> INSERT INTO `scores` (`asked`, `saving`, `confusion`, `created`)
> VALUES (5, 5.857142857142857, 5.123350661145302, '2010-07-13 12:47:49')

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Validation problem

2010-07-13 Thread McBuck DGAF
Sorry, I wasn't looking at the regex itself, I was just looking at the
way you implemented it (and we have not addressed your 'company_name'
issue at all, but the solution here should be readily adaptable to
that).

I am no regex expert, but wouldn't the following get you what you
want?:

'rule' => '/^[a-z]$/i',

 (the regex must be delimited by "/", which is probably the source of
your current error)

On Jul 12, 7:18 pm, Felix  wrote:

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


CakePHP 1.3 Form Samples with default value

2010-07-13 Thread Azril Nazli
Might be useful for somebody, here's the sample

http://azrilnazli.blogspot.com/2010/07/cakephp-13-form-samples-with-default.html

Pastebin : http://pastebin.com/MAekWJCt

in the controller just debug the inconing value, enjoy


Azril Nazli
Putrajaya, Malaysia

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Fatal error: Allowed memory size of 16777216 bytes exhausted

2010-07-13 Thread Jeremy Burns | Class Outfit
I'd also check your model associations and controller code to check that you 
are not in a recursive loop, retrieving too much data or have some other 
gotcha. IMO, I think it's better to get to and fix the root cause rather than 
just paper over it. If your memory is really being stretched, then you will not 
have optimum performance.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 13 Jul 2010, at 12:58, Ayman Bedair wrote:

> This happened with me on the local windows server while testing,
> didn't really see the problem up on my live one.
> 
> Anyway if u have access to the PHP.INI file you can just go there and
> edit the "memory_limit = 16M" value to something like "memory_limit =
> 50M". I had this set to 150MB and it didn't affect the computer
> stability so go up until it's sufficient for you app to run. (You need
> to restart your server after changing this value for the new settings
> to take effect)
> 
> If this is not a convenient solution try setting the debug to 0 and
> the  "var $persistModel = false;" in your controllers. That should
> save up some of the memory space I believe.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Fatal error: Allowed memory size of 16777216 bytes exhausted

2010-07-13 Thread Ayman Bedair
This happened with me on the local windows server while testing,
didn't really see the problem up on my live one.

Anyway if u have access to the PHP.INI file you can just go there and
edit the "memory_limit = 16M" value to something like "memory_limit =
50M". I had this set to 150MB and it didn't affect the computer
stability so go up until it's sufficient for you app to run. (You need
to restart your server after changing this value for the new settings
to take effect)

If this is not a convenient solution try setting the debug to 0 and
the  "var $persistModel = false;" in your controllers. That should
save up some of the memory space I believe.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How to handle Jaywalking - parsing a comma-delimited value in field and do lookups (1,4,5,6...)

2010-07-13 Thread Snaky Love
Hi,

I have an "interesting" problem here - in a given mysql database
scheme some sql wizard used comma-separated values in a text-field and
with that values lookups have to be done. The data itself is simple
numbers like 1,34,25,66,78,134 and so on. So what I have is something
like this:

id | username | groups | more...
-
1 | name| 1,23,4,55,6  | ...
2 | name2  | 3,2,4,5| ...

The groups string can be very long. there is also a table "groups"
with "id, name", as expected.

Yes, this is bad design. No, I can not immediately change the design,
I will try to, but atm I have to handle the situation as it is.

Of course normally this would be solved with an intersection table and
a many-to-many relation. For anybody interested: there is a book by
Bill Karwin called "SQL Antipatterns" - he names the described design
Jaywalking and it is the first antipattern in the book. I was
surprised to find it in real life

So my question is: how to handle this with cakephp? I really would
like to use cake to bake a nice management interface on top of that
tables, but currently I do not know how to go on with that jaywalking
antipattern in my way.

My first idea was to create my own intersection table - but the
process of [re-]converting data forth and back does only work in a
static environment - but the data is heavily used and so
transformations of tabledata would be neccassery on every request to
mirror the live situation... so I am looking for a good way to
implement some kind of layer that would translate this filed for
cakephp into an intersaection table so that I can use cake models -
maybe a kind of datasource? Will this work?

What do you think? How to handle this?

Thank you very much for your attention!
Snaky

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Problems with cookies

2010-07-13 Thread Iancu Dragos
Hi,

I have a problem using cookies in cakephp 1.3.2

When i write a new cookie it works but it gives me this error:
Warning (2): srand() expects parameter 1 to be long, string given
[CORE/cake/libs/security.php, line 177]

When i`m trying to read the cookie it returns me something like that:
array(1) { ["�Y�� d...@i"]=>  string(40) "ٟ� �`d�y��^PԱ�:
�o NP ��5��j�$ �S" }

Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Too many SQL queries!!

2010-07-13 Thread Mike Karthauser
hi alex

On Tue, July 13, 2010 11:57 am, Alex Bovey wrote:
> Well, my debug level is 0 for production but since I can't see the SQL log
> I'm turning it to 2 for debugging.
>
> Can I get cake to log the SQL somewhere and still set debug to 0?
>
> Interestingly I found this, which seems to imply that Containable is the
> cause of the problem, rather than the solution:
>
> http://www.endyourif.com/cakephp-containable-statement-pitfalls/
>
> Indeed if I stop using containable and instead set recursive to 0 or 1, I
> get fewer queries.
>
> Hmm, maybe it's time to start writing custom queries?

refining by writing custom queries can be useful but having found an issue
recently where repeated custom queries were stealing memory and not being
cleared by garbage collection, i'd be a bit wary of this as a solution.

if you do have issues with lots of queries, then you might also be worth
looking at view/ object caching if they are having performance issues on
your application.

you'd also be worth moving up to a more recent version of cake1.2 as the
recent code releases are more optimised than the version you are using.

mikek


>
> On Tue, Jul 13, 2010 at 10:58 AM, Jeremy Burns | Class Outfit <
> jeremybu...@classoutfit.com> wrote:
>
>> Out of interest, what is your debug level?
>>
>> Jeremy Burns
>> *Class Outfit*
>> *
>> *
>> jeremybu...@classoutfit.com 
>> http://www.classoutfit.com
>>
>> On 13 Jul 2010, at 10:57, Alex Bovey wrote:
>>
>> Hi Nick,
>>
>> Thanks for the reply.
>>
>> Sorry I should have said in my original post - I'm already using
>> Containable AND setting recursive to -1 in app_model.php.
>>
>> But still the selects are incredibly inefficient - a single query to
>> fetch
>> each individual row?!
>>
>> I'm not specifying 'fields' but surely that's not going to mean the
>> difference between what should be 2 queries at most, and the thousands
>> I'm
>> ending up with...
>>
>> Thanks,
>>
>> Alex
>>
>> On Tue, Jul 13, 2010 at 9:59 AM, nurvzy  wrote:
>>
>>> Use a mixture of:
>>>
>>> fields option key (so you're not retrieving data you don't intend to
>>> use),
>>> containable (so you're not selecting associative models and their
>>> fields you don't care about),
>>> and set recursive = -1 in your app_model.php
>>>
>>> The first thing I do whenever I start any new CakePHP project is open
>>> up app_model.php and add actsAs = array('Containable') and recursive =
>>> -1.
>>>
>>> I suggest you take advantage of the containable component.  Read about
>>> it here:
>>> http://book.cakephp.org/view/474/Containable
>>>
>>> Hope that helps,
>>> Nick
>>>
>>> On Jul 13, 2:35 am, Alex Bovey  wrote:
>>> > Hi all,
>>> >
>>> > Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
>>> > queries in my app.
>>> >
>>> > For example, I have Enquiry belongsTo User and User hasMany Enquiry.
>>> >
>>> > A simple $this->Enquiry->find('all') results in one query to fetch
>>> the
>>> > enquiries, and then a separate query for every single Enquiry to
>>> fetch
>>> the
>>> > User for that Enquiry.
>>> >
>>> > When I have more complex model relations I'm ending up with over
>>> 10,000
>>> SQL
>>> > queries.
>>> >
>>> > What am I doing wrong?!
>>> >
>>> > Thanks,
>>> >
>>> > Alex
>>>
>>> Check out the new CakePHP Questions site http://cakeqs.org and help
>>> others with their CakePHP related questions.
>>>
>>> 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
>>> cake-php+unsubscr...@googlegroups.comFor
>>> more options, visit this group at
>>> http://groups.google.com/group/cake-php?hl=en
>>>
>>
>>
>>
>> --
>> Alex Bovey
>> Web Developer | Alex Bovey Consultancy Ltd
>> Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
>> a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
>> PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others
>> with their CakePHP related questions.
>>
>> 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
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php?hl=en
>>
>>
>>  Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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
>> cake-php+unsubscr...@googlegroups.comFor
>> more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>
>
> --
> Alex Bovey
> Web Developer | Alex

saveAll recursive?

2010-07-13 Thread tersmitten
I have these relations:

'Questionnaire'
var $hasMany = array('Answer', 'Score');

'Answer'
var $belongsTo = array('Questionnaire');

'Score'
  var $belongsTo = array('Questionnaire');

  var $hasMany = array('Distribution');

'Distribution'
var $belongsTo = array('Score');

And this $this->data array:

Array
(
[Score] => Array
(
[questionnaire_id] => 1
[asked] => 6
[saving] => 0.857142857142857
[confusion] => 0.123350661145302
)

[Answer] => Array
(
[0] => Array
(
[questionnaire_id] => 1
[nr] => 38
[gain] => 0.617120315940921
[answer] => 0
)

[1] => Array
(
[questionnaire_id] => 1
[nr] => 27
[gain] => 0.579630589271582
[answer] => 0
)

[2] => Array
(
[questionnaire_id] => 1
[nr] => 37
[gain] => 0.630463961500971
[answer] => 0
)

[3] => Array
(
[questionnaire_id] => 1
[nr] => 21
[gain] => 0.573958382547494
[answer] => 0
)

[4] => Array
(
[questionnaire_id] => 1
[nr] => 31
[gain] => 0.541071733269663
[answer] => 0
)

[5] => Array
(
[questionnaire_id] => 1
[nr] => 16
[gain] => 0.518019986628517
[answer] => 0
)

)

[Distribution] => Array
(
[0] => Array
(
[score_id] => 0
[node_id] => 0
[outcome_id] => 0
[outcome] => 0.876649338854698
)

[1] => Array
(
[score_id] => 0
[node_id] => 0
[outcome_id] => 1
[outcome] => 0.121184205629772
)

[2] => Array
(
[score_id] => 0
[node_id] => 0
[outcome_id] => 2
[outcome] => 0.00215701160505212
)

[3] => Array
(
[score_id] => 0
[node_id] => 0
[outcome_id] => 3
[outcome] => 9.44391047793026E-06
)

[4] => Array
(
[score_id] => 0
[node_id] => 1
[outcome_id] => 0
[outcome] => 0.973397460859459
)

[5] => Array
(
[score_id] => 0
[node_id] => 1
[outcome_id] => 1
[outcome] => 0.0266018207544375
)

[6] => Array
(
[score_id] => 0
[node_id] => 1
[outcome_id] => 2
[outcome] => 7.18385702671455E-07
)

[7] => Array
(
[score_id] => 0
[node_id] => 1
[outcome_id] => 3
[outcome] => 4.00454525238331E-13
)

[8] => Array
(
[score_id] => 0
[node_id] => 2
[outcome_id] => 0
[outcome] => 0.53819737554949
)

[9] => Array
(
[score_id] => 0
[node_id] => 2
[outcome_id] => 1
[outcome] => 0.426324044777277
)

[10] => Array
(
[score_id] => 0
[node_id] => 2
[outcome_id] => 2
[outcome] => 0.0339819742833485
)

[11] => Array
(
[score_id] => 0
[node_id] => 2
[outcome_id] => 3
[outcome] => 0.00149660538988473
)

[12] => Array
(
[score_id] => 0
[node_id] => 3
[outcome_id] => 0
[outcome] => 0.90672775375481
)

[13] => Array
(
[score_id] => 0
[node_id] => 3
[outcome_id] => 1
[outcome] => 0.08961241930

saveAll changing $this->data

2010-07-13 Thread tersmitten
I'm trying to save my $this->data which is (already) a correct array.
But when I do and look at my queries it looks like saveAll has changed
my array. Why?

Original array:
Array
(
[Score] => Array
(
[questionnaire_id] => 1
[asked] => 6
[saving] => 0.857142857142857
[confusion] => 0.123350661145302
)
)

Sql queries:

INSERT INTO `scores` (`asked`, `saving`, `confusion`, `created`)
VALUES (5, 5.857142857142857, 5.123350661145302, '2010-07-13 12:47:49')

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Too many SQL queries!!

2010-07-13 Thread Alex Bovey
Well, my debug level is 0 for production but since I can't see the SQL log
I'm turning it to 2 for debugging.

Can I get cake to log the SQL somewhere and still set debug to 0?

Interestingly I found this, which seems to imply that Containable is the
cause of the problem, rather than the solution:

http://www.endyourif.com/cakephp-containable-statement-pitfalls/

Indeed if I stop using containable and instead set recursive to 0 or 1, I
get fewer queries.

Hmm, maybe it's time to start writing custom queries?

On Tue, Jul 13, 2010 at 10:58 AM, Jeremy Burns | Class Outfit <
jeremybu...@classoutfit.com> wrote:

> Out of interest, what is your debug level?
>
> Jeremy Burns
> *Class Outfit*
> *
> *
> jeremybu...@classoutfit.com 
> http://www.classoutfit.com
>
> On 13 Jul 2010, at 10:57, Alex Bovey wrote:
>
> Hi Nick,
>
> Thanks for the reply.
>
> Sorry I should have said in my original post - I'm already using
> Containable AND setting recursive to -1 in app_model.php.
>
> But still the selects are incredibly inefficient - a single query to fetch
> each individual row?!
>
> I'm not specifying 'fields' but surely that's not going to mean the
> difference between what should be 2 queries at most, and the thousands I'm
> ending up with...
>
> Thanks,
>
> Alex
>
> On Tue, Jul 13, 2010 at 9:59 AM, nurvzy  wrote:
>
>> Use a mixture of:
>>
>> fields option key (so you're not retrieving data you don't intend to
>> use),
>> containable (so you're not selecting associative models and their
>> fields you don't care about),
>> and set recursive = -1 in your app_model.php
>>
>> The first thing I do whenever I start any new CakePHP project is open
>> up app_model.php and add actsAs = array('Containable') and recursive =
>> -1.
>>
>> I suggest you take advantage of the containable component.  Read about
>> it here:
>> http://book.cakephp.org/view/474/Containable
>>
>> Hope that helps,
>> Nick
>>
>> On Jul 13, 2:35 am, Alex Bovey  wrote:
>> > Hi all,
>> >
>> > Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
>> > queries in my app.
>> >
>> > For example, I have Enquiry belongsTo User and User hasMany Enquiry.
>> >
>> > A simple $this->Enquiry->find('all') results in one query to fetch the
>> > enquiries, and then a separate query for every single Enquiry to fetch
>> the
>> > User for that Enquiry.
>> >
>> > When I have more complex model relations I'm ending up with over 10,000
>> SQL
>> > queries.
>> >
>> > What am I doing wrong?!
>> >
>> > Thanks,
>> >
>> > Alex
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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
>> cake-php+unsubscr...@googlegroups.comFor
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>
>
> --
> Alex Bovey
> Web Developer | Alex Bovey Consultancy Ltd
> Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
> a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
> PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php?hl=en
>
>
>  Check out the new CakePHP Questions site http://cakeqs.org and help
> others with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Fatal error: Allowed memory size of 16777216 bytes exhausted

2010-07-13 Thread vanishri
HI,

Am using cake php for my application .it is throwing an error
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to
allocate 48 bytes) in /var/www/mycake/cake/libs/model/datasources/dbo/
dbo_mysql.php on line 648


can any one please reply me with the solution to over come by this
problem


Thanks,
Vanishri

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: when and why using different models/controllers?

2010-07-13 Thread Tomfox Wiranata
thx to both of you. then i am on the right track :)

appreciate it

On 13 Jul., 11:39, Jeremy Burns | Class Outfit
 wrote:
> A spot on reply. A broad brush to view it is to start from the database and 
> create a model/controller/views for each table. That will take you pretty 
> near where you want to go, and then you can start to combine things together.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 13 Jul 2010, at 10:16, nurvzy wrote:
>
> > Ok, so the issue here is you're still thinking about your website/app
> > as a basic procedural script.  Which isn't that hard to do, as that is
> > kind of the life cycle of a standard HTTP request.  However, the trick
> > here is to stop thinking about your website as your basic php
> > procedural script, and start thinking of it in an Object Oriented
> > manner.  This can be a tough thing to wrap your head around at first.
> > It was for me, and everyone other developer I've talked to.  It's an
> > odd thing, eventually it will all just click, like a light goes on
> > above your head, and at least for me it was rather sudden.
>
> > I mean by Object Oriented, is thinking about the various actions,
> > logic, and data types you want your website to manager/show/manipulate
> > and describe them as objects in your mind.  What can a User do,
> > (register, login, logout, view past orders, etc...)?  What can a Post
> > do (create, edit, show most recent, etc...)?  What can a Download do
> > (stream the content, share to facebook, etc...)?  These 'actions' that
> > you can preform on an object will be your various functions.   Now
> > that you've described all the objects in your application its now time
> > to convert those objects into Models.  A model, in most cases, is a
> > singular form of your object and is really in charge of handling all
> > the data needed to describe that object (User, Post, Download).
> > Controllers are the plural form of your objects, used to manage/
> > combine/format groups of objects for various uses (Users, Posts,
> > Downloads).
>
> > So, to answer your question, if you're describing something new, its
> > best practice to create another model/controller pairing for the new
> > object.  The beauty if CakePHP is the extreme ease it gives us to
> > associate objects together.  This helps us make some really complex
> > and intricate data structures from many smaller objects all put
> > together.
>
> > I hope that helps,
> > Nick
>
> > On Jul 13, 1:53 am, Tomfox Wiranata  wrote:
> >> hi,
>
> >> so far i used one controller/model for the whole user management
> >> (login, logout, register, profile etc.).
>
> >> now I am heading to a different milestone with my website, and the
> >> user is not in focus anymore. so it makes sense to create a new
> >> controller/model, right? but that seems more like a logical/
> >> philosophical thing to me.
>
> >> i guess technically it does not matter if i use 1 controller/model for
> >> all or different ones. is that right? if not, when should i use
> >> different ones?
>
> >> thx :)
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Too many SQL queries!!

2010-07-13 Thread Jeremy Burns | Class Outfit
Out of interest, what is your debug level?

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 13 Jul 2010, at 10:57, Alex Bovey wrote:

> Hi Nick,
> 
> Thanks for the reply.
> 
> Sorry I should have said in my original post - I'm already using Containable 
> AND setting recursive to -1 in app_model.php.
> 
> But still the selects are incredibly inefficient - a single query to fetch 
> each individual row?!
> 
> I'm not specifying 'fields' but surely that's not going to mean the 
> difference between what should be 2 queries at most, and the thousands I'm 
> ending up with...
> 
> Thanks,
> 
> Alex
> 
> On Tue, Jul 13, 2010 at 9:59 AM, nurvzy  wrote:
> Use a mixture of:
> 
> fields option key (so you're not retrieving data you don't intend to
> use),
> containable (so you're not selecting associative models and their
> fields you don't care about),
> and set recursive = -1 in your app_model.php
> 
> The first thing I do whenever I start any new CakePHP project is open
> up app_model.php and add actsAs = array('Containable') and recursive =
> -1.
> 
> I suggest you take advantage of the containable component.  Read about
> it here:
> http://book.cakephp.org/view/474/Containable
> 
> Hope that helps,
> Nick
> 
> On Jul 13, 2:35 am, Alex Bovey  wrote:
> > Hi all,
> >
> > Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
> > queries in my app.
> >
> > For example, I have Enquiry belongsTo User and User hasMany Enquiry.
> >
> > A simple $this->Enquiry->find('all') results in one query to fetch the
> > enquiries, and then a separate query for every single Enquiry to fetch the
> > User for that Enquiry.
> >
> > When I have more complex model relations I'm ending up with over 10,000 SQL
> > queries.
> >
> > What am I doing wrong?!
> >
> > Thanks,
> >
> > Alex
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 
> 
> 
> -- 
> Alex Bovey
> Web Developer | Alex Bovey Consultancy Ltd
> Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
> a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
> PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>  
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Too many SQL queries!!

2010-07-13 Thread Alex Bovey
Hi Nick,

Thanks for the reply.

Sorry I should have said in my original post - I'm already using Containable
AND setting recursive to -1 in app_model.php.

But still the selects are incredibly inefficient - a single query to fetch
each individual row?!

I'm not specifying 'fields' but surely that's not going to mean the
difference between what should be 2 queries at most, and the thousands I'm
ending up with...

Thanks,

Alex

On Tue, Jul 13, 2010 at 9:59 AM, nurvzy  wrote:

> Use a mixture of:
>
> fields option key (so you're not retrieving data you don't intend to
> use),
> containable (so you're not selecting associative models and their
> fields you don't care about),
> and set recursive = -1 in your app_model.php
>
> The first thing I do whenever I start any new CakePHP project is open
> up app_model.php and add actsAs = array('Containable') and recursive =
> -1.
>
> I suggest you take advantage of the containable component.  Read about
> it here:
> http://book.cakephp.org/view/474/Containable
>
> Hope that helps,
> Nick
>
> On Jul 13, 2:35 am, Alex Bovey  wrote:
> > Hi all,
> >
> > Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
> > queries in my app.
> >
> > For example, I have Enquiry belongsTo User and User hasMany Enquiry.
> >
> > A simple $this->Enquiry->find('all') results in one query to fetch the
> > enquiries, and then a separate query for every single Enquiry to fetch
> the
> > User for that Enquiry.
> >
> > When I have more complex model relations I'm ending up with over 10,000
> SQL
> > queries.
> >
> > What am I doing wrong?!
> >
> > Thanks,
> >
> > Alex
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: when and why using different models/controllers?

2010-07-13 Thread Jeremy Burns | Class Outfit
A spot on reply. A broad brush to view it is to start from the database and 
create a model/controller/views for each table. That will take you pretty near 
where you want to go, and then you can start to combine things together.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 13 Jul 2010, at 10:16, nurvzy wrote:

> Ok, so the issue here is you're still thinking about your website/app
> as a basic procedural script.  Which isn't that hard to do, as that is
> kind of the life cycle of a standard HTTP request.  However, the trick
> here is to stop thinking about your website as your basic php
> procedural script, and start thinking of it in an Object Oriented
> manner.  This can be a tough thing to wrap your head around at first.
> It was for me, and everyone other developer I've talked to.  It's an
> odd thing, eventually it will all just click, like a light goes on
> above your head, and at least for me it was rather sudden.
> 
> I mean by Object Oriented, is thinking about the various actions,
> logic, and data types you want your website to manager/show/manipulate
> and describe them as objects in your mind.  What can a User do,
> (register, login, logout, view past orders, etc...)?  What can a Post
> do (create, edit, show most recent, etc...)?  What can a Download do
> (stream the content, share to facebook, etc...)?  These 'actions' that
> you can preform on an object will be your various functions.   Now
> that you've described all the objects in your application its now time
> to convert those objects into Models.  A model, in most cases, is a
> singular form of your object and is really in charge of handling all
> the data needed to describe that object (User, Post, Download).
> Controllers are the plural form of your objects, used to manage/
> combine/format groups of objects for various uses (Users, Posts,
> Downloads).
> 
> So, to answer your question, if you're describing something new, its
> best practice to create another model/controller pairing for the new
> object.  The beauty if CakePHP is the extreme ease it gives us to
> associate objects together.  This helps us make some really complex
> and intricate data structures from many smaller objects all put
> together.
> 
> I hope that helps,
> Nick
> 
> On Jul 13, 1:53 am, Tomfox Wiranata  wrote:
>> hi,
>> 
>> so far i used one controller/model for the whole user management
>> (login, logout, register, profile etc.).
>> 
>> now I am heading to a different milestone with my website, and the
>> user is not in focus anymore. so it makes sense to create a new
>> controller/model, right? but that seems more like a logical/
>> philosophical thing to me.
>> 
>> i guess technically it does not matter if i use 1 controller/model for
>> all or different ones. is that right? if not, when should i use
>> different ones?
>> 
>> thx :)
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: when and why using different models/controllers?

2010-07-13 Thread nurvzy
Ok, so the issue here is you're still thinking about your website/app
as a basic procedural script.  Which isn't that hard to do, as that is
kind of the life cycle of a standard HTTP request.  However, the trick
here is to stop thinking about your website as your basic php
procedural script, and start thinking of it in an Object Oriented
manner.  This can be a tough thing to wrap your head around at first.
It was for me, and everyone other developer I've talked to.  It's an
odd thing, eventually it will all just click, like a light goes on
above your head, and at least for me it was rather sudden.

I mean by Object Oriented, is thinking about the various actions,
logic, and data types you want your website to manager/show/manipulate
and describe them as objects in your mind.  What can a User do,
(register, login, logout, view past orders, etc...)?  What can a Post
do (create, edit, show most recent, etc...)?  What can a Download do
(stream the content, share to facebook, etc...)?  These 'actions' that
you can preform on an object will be your various functions.   Now
that you've described all the objects in your application its now time
to convert those objects into Models.  A model, in most cases, is a
singular form of your object and is really in charge of handling all
the data needed to describe that object (User, Post, Download).
Controllers are the plural form of your objects, used to manage/
combine/format groups of objects for various uses (Users, Posts,
Downloads).

So, to answer your question, if you're describing something new, its
best practice to create another model/controller pairing for the new
object.  The beauty if CakePHP is the extreme ease it gives us to
associate objects together.  This helps us make some really complex
and intricate data structures from many smaller objects all put
together.

I hope that helps,
Nick

On Jul 13, 1:53 am, Tomfox Wiranata  wrote:
> hi,
>
> so far i used one controller/model for the whole user management
> (login, logout, register, profile etc.).
>
> now I am heading to a different milestone with my website, and the
> user is not in focus anymore. so it makes sense to create a new
> controller/model, right? but that seems more like a logical/
> philosophical thing to me.
>
> i guess technically it does not matter if i use 1 controller/model for
> all or different ones. is that right? if not, when should i use
> different ones?
>
> thx :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Too many SQL queries!!

2010-07-13 Thread nurvzy
Use a mixture of:

fields option key (so you're not retrieving data you don't intend to
use),
containable (so you're not selecting associative models and their
fields you don't care about),
and set recursive = -1 in your app_model.php

The first thing I do whenever I start any new CakePHP project is open
up app_model.php and add actsAs = array('Containable') and recursive =
-1.

I suggest you take advantage of the containable component.  Read about
it here:
http://book.cakephp.org/view/474/Containable

Hope that helps,
Nick

On Jul 13, 2:35 am, Alex Bovey  wrote:
> Hi all,
>
> Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
> queries in my app.
>
> For example, I have Enquiry belongsTo User and User hasMany Enquiry.
>
> A simple $this->Enquiry->find('all') results in one query to fetch the
> enquiries, and then a separate query for every single Enquiry to fetch the
> User for that Enquiry.
>
> When I have more complex model relations I'm ending up with over 10,000 SQL
> queries.
>
> What am I doing wrong?!
>
> Thanks,
>
> Alex

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Too many SQL queries!!

2010-07-13 Thread Alex Bovey
Hi all,

Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
queries in my app.

For example, I have Enquiry belongsTo User and User hasMany Enquiry.

A simple $this->Enquiry->find('all') results in one query to fetch the
enquiries, and then a separate query for every single Enquiry to fetch the
User for that Enquiry.

When I have more complex model relations I'm ending up with over 10,000 SQL
queries.

What am I doing wrong?!

Thanks,

Alex

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


when and why using different models/controllers?

2010-07-13 Thread Tomfox Wiranata
hi,

so far i used one controller/model for the whole user management
(login, logout, register, profile etc.).

now I am heading to a different milestone with my website, and the
user is not in focus anymore. so it makes sense to create a new
controller/model, right? but that seems more like a logical/
philosophical thing to me.

i guess technically it does not matter if i use 1 controller/model for
all or different ones. is that right? if not, when should i use
different ones?

thx :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Cakephp and XAMPP installation nightmare, Can't get cake to understand root

2010-07-13 Thread Tomfox Wiranata
http://book.cakephp.org/view/1528/Blog

do it step by step..its the perfect way to understand cake..

On 12 Jul., 01:20, Dinu464  wrote:
> 1) XAMPP 1.7.3 setup and workinghttp://localhost/xampp/-> success
> 2) Unpacked cake1.3.2, installed under XAMPP -> htdocs -> cake1.3.2
> (folder)
> Checked setuphttp://localhost/cake1.3.2/-> success
>
> Your tmp directory is writable.
> The FileEngine is being used for caching. To change the config edit
> APP/config/core.php
> Your database configuration file is present.
> Cake is able to connect to the database.
>
> 3) Trying to Implement IBM tutorial Part1
>
> Created MySQL tabel 'Users'
> under cake1.3.2\app\models, created user.php
> under cake1.3.2\app\controllers, created users_controller.php, with
> action registration
> under cake1.3.2\app\view\users, created registration.ctp
>
> 4) nowhttp://localhost/cake1.3.2/app/views/users/registeration
>
> throws an err
>
> Error: ViewsController could not be found.
> Error: Create the class ViewsController below in file: app\controllers
> \views_controller.php
>  class ViewsController extends AppController {
>
>     var $name = 'Views';}
>
> ?>
>
> This is where I am stuck for a week now, can’t get passed this screen,
> tried several solutions but still cant get this to work..really
> frustrated. please help!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: cake 1.3.2 wants to be too smart

2010-07-13 Thread Grzegorz Pawlik
That's not what I'm asking about. Lets say I NEED to use TIMESTAMP and
CURRENT_TIMESTAMP as default value, and in that case cakePHP
misbehaves.

On Jul 13, 7:04 am, Walther  wrote:
> I've never seen that problem before...
>
> Cake offers the same functionality, it is well documented in every
> book. Basically you crater a field called created or updated as a
> datetime, default null and cake will populate it automatically.
>
> On Jul 12, 5:02 pm, Grzegorz Pawlik  wrote:
>
> > just switching from 1.3.0 to 1.3.2 got me into trouble, when I have
> > field specified as:
>
> >   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
>
> > and don't supply any value for that field in array I try to save ,
> > neither a key in
> > 1.3.0 it's working as desired - I get current timestamp in that field,
> > but
> > 1.3.2 tries looks that's it not null field, and read default value
> > (CURRENT_TIMESTAMP) ant unfortunatelly polupulates this array with
> > that pair of key/val:
> > "createt_at"=>"CURRENT_TIMESTAMP"
> > which is basically stupid for two reasons, I think:
> > 1. It tries to duplicate database mechanisms which are working just
> > fine (when no value - use default value, no need to to that:
> > if no value, check what's default value defined in database and
> > explicitly save data with that value)
> > 2. It makes CURRENT_TIMESTAMP not working
>
> > is there a way to turn that behavior off?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en