Re: how to display a different field name from the database in the model
This should be taken care of by your view. You'd do something like this in your form: ?php echo $form-input('name_en_gb', array('label' = __('name', true))); ? Good Luck! Christian - Original Message - From: robert123 [EMAIL PROTECTED] To: CakePHP cake-php@googlegroups.com Sent: Saturday, October 04, 2008 9:32 PM Subject: how to display a different field name from the database in the model hi in my database there is a field which is name_en_gb in my model i wanted it to read the field, but display it as the field name can anyone let me know how to do it, thank you --~--~-~--~~~---~--~~ 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: how to display a different field name from the database in the model
If you mean display to the user I don't see where the problem is. If you're talking about scaffolding, just make a proper view. If you mean change internally it's more hassle than it's worth IMHO. Can you clarify a bit what you want to do and where you're stuck? On 5 Oct 2008, at 10:32, robert123 wrote: hi in my database there is a field which is name_en_gb in my model i wanted it to read the field, but display it as the field name can anyone let me know how to do it, thank you --~--~-~--~~~---~--~~ 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: how to display a different field name from the database in the model
hi, Thank you, I have a cakephp application, the product model has the 'name' field, and all the codes, that is the controller, view, call that field as 'name'. but right now the product table in the database which has the field 'name' has been changed to 'name_en_gb', I am wondering, is there any small change in the model I can do such that it will read the 'name_en_gb' field in the product table in the database, but at the code level, the view, controller, etc can access it using the 'name' field. Thank you On Oct 5, 2:21 pm, David C. Zentgraf [EMAIL PROTECTED] wrote: If you mean display to the user I don't see where the problem is. If you're talking about scaffolding, just make a proper view. If you mean change internally it's more hassle than it's worth IMHO. Can you clarify a bit what you want to do and where you're stuck? On 5 Oct 2008, at 10:32, robert123 wrote: hi in my database there is a field which is name_en_gb in my model i wanted it to read the field, but display it as the field name can anyone let me know how to do it, thank you --~--~-~--~~~---~--~~ 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: how to display a different field name from the database in the model
You should really look into changing the variable name in the code. With searchreplace this may be the best option. Otherwise, you could do that in the model with the afterFind callback. Just copy the field: $model['name'] = $model['name_en_gb']; But you're setting yourself up for all kinds of problems with this, as you'll have to convert back and forth between the database and application. On 5 Oct 2008, at 15:36, robert123 wrote: hi, Thank you, I have a cakephp application, the product model has the 'name' field, and all the codes, that is the controller, view, call that field as 'name'. but right now the product table in the database which has the field 'name' has been changed to 'name_en_gb', I am wondering, is there any small change in the model I can do such that it will read the 'name_en_gb' field in the product table in the database, but at the code level, the view, controller, etc can access it using the 'name' field. Thank you On Oct 5, 2:21 pm, David C. Zentgraf [EMAIL PROTECTED] wrote: If you mean display to the user I don't see where the problem is. If you're talking about scaffolding, just make a proper view. If you mean change internally it's more hassle than it's worth IMHO. Can you clarify a bit what you want to do and where you're stuck? On 5 Oct 2008, at 10:32, robert123 wrote: hi in my database there is a field which is name_en_gb in my model i wanted it to read the field, but display it as the field name can anyone let me know how to do it, thank you --~--~-~--~~~---~--~~ 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: How to save extra field in join table in HATBM Cake1.2
Hi Andre, In the HABTM relationship definition you can define an attribute 'with' where you can specify which model acts as the HABTM model (in your case posts_tags). Then you can create the posts_tags model which gets saved with the additional fields. I have not experimented with it but I saw some articles/posts about this a few days ago (a quick search did not turn up any useful links so you'll have to search for yourself). Hope this helps (or at least a little ;)). Good luck! GrandiJoos On 4 okt, 18:28, Andre [EMAIL PROTECTED] wrote: Hi all, I saw Storing additional data on join tablehttps://trac.cakephp.org/ticket/828. Having, two tables associated with HABTM: tags, posts, posts_tags posts_tags{ post_id,tag_id,weight } Can anyone help me showing how to use it, in the Post 's add or Post 's edit view in to populate weight field in posts_tags.weight column? I am thinking to use Checkbox options to select related posts_tags.weight, And input text to enter weight. I've been struggling with this issue for few weeks with HABTM where the join table record is deleted and reinserted everytime, thus the posts_tags.weight column were never saved? Thanks --~--~-~--~~~---~--~~ 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: HABTM - SQL Error 1062 w/ 1.2 RC3
I'm replying to myself. The issue is basically related to the fact that HABTM table and its fields must be in alphabetical order. So, if I want a post in many languages, I should use: languages_posts as the relation table The columns must be: language_id post_id as a united primary index I think that this is due to the fact that cakephp in using a ordered sintax in specifing values in INSERT queries. Cheers Julien On 5 Ott, 01:22, イタリア人 [EMAIL PROTECTED] wrote: Hi, the issue does not get solved with removing indexes... it simply double (and invent) some associations which are not clear on RC3 On 4 Ott, 16:19, nachopitt [EMAIL PROTECTED] wrote: Glad to hear that, I was about to ask information for primary keys or maybe a unique index including both foreign keys. On Oct 4, 12:25 am, Keith [EMAIL PROTECTED] wrote: Nevermind...lol too late to be coding... For some reason the user_id column in the departments_users table had been set as a primarykey. I'm not exactly sure why, but who knows maybe I totally bailed and set a primarykeyflag somewhere along the line. Everything is working though. On 4 Oct, 01:12, Keith [EMAIL PROTECTED] wrote: I have a situation where I have a user model a department model. MODEL - User.php var $hasAndBelongsToMany = array( 'Department' = array('className' = 'Department', 'joinTable' = 'departments_users', 'foreignKey' = 'user_id', 'associationForeignKey' = 'department_id', 'unique' = true, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'finderQuery' = '', 'deleteQuery' = '', 'insertQuery' = '' ) ); MODEL - department.php var $hasAndBelongsToMany = array( 'User' = array('className' = 'User', 'joinTable' = 'departments_users', 'foreignKey' = 'department_id', 'associationForeignKey' = 'user_id', 'unique' = true, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'finderQuery' = '', 'deleteQuery' = '', 'insertQuery' = '' ) ); So...my problem is this: I baked my application's controllers, views, and models via the console and they are still the defaults. I currently have 2 users 2 departments in the database. Whenever I associate a user with a single department (doesn't matter which one) everything works fine. Whenever I associate a user with both departments I get the following error: Warning (512): SQL Error: 1062:Duplicateentry '2' forkey1 [CORE/ cake/libs/model/datasources/dbo_source.php, line 521] Query: INSERT INTO `departments_users` (`user_id`,`department_id`) VALUES (2,'1'), (2,'2') Any help would be greatly appreciated. This project was created exclusively with the 1.2 RC3 so it wasn't an upgrade or anything like that from RC2 or before. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
security component
i have multiple forms in one page. when I add var $components=array('Security'); component (without doing anything else), i notice that it only adds the security token to the first form on the page. How do I get it on all of the forms? thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
sanitize::html - newline problem
i am trying to use sanitize::html. my problem is that it even removes new line characters \n, which i want to keep. how would you handle this in cake? thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how i use the cakephp session in vendor module?
hi, i am new in cakephp. i have a problem in using the third party module e;g. chat i want to use the cakephp session in this module when i print the session variable in cakephp controller it shows the value but in third party modules i am not able to get the session variables y pleas any one can help me? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Any truth to charge of 'thousands of db queries' ?
Some months ago I read an anti-cake / fear mongering message, something about how cakephp routinely makes thousands of database queries to accomplish typical, regular actions. Guess what? Fear was mongered. Not trying to monger more fear, just wondering (1) was there any truth to that, and (2) if so, what, if anything, is being done about it? --~--~-~--~~~---~--~~ 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: Release: CakePHP RC3 - The RC of Triumph!
Hey folks, Sounds great what RC3 offering to us. Everything seems get faster. Is RC2 really slow compare to RC3, anyway? I haven't look at RC3, and I have no idea how I will compare them (RC2 and RC3). But surely I'm getting deep with this cake's stuff. So sweet... Hopefully will contributed something to the community soon. Thanks to all for making this happen. I'm looking forward to use the new release. Cheers, ketut Happy Mark Story Day :) On Oct 4, 1:51 am, Mathew [EMAIL PROTECTED] wrote: Thanks so much for all the hard work guys! Special thanks to Mark Story, because bugs I reported were fixed the next day by him. He's so fast! Thanks for all the hard work Mark! --~--~-~--~~~---~--~~ 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: Does calling model methods from elements break MVC pattern?
I'm really curious about this topic as well as it speaks to an aspect of the CakePHP Model class that has never really clicked with me. Andrea's example is perfect for explaining the point. In most MVC frameworks, when you retrieve data from storage (ram, db, file, etc), you usually get an instance of the model class itself, not a map/dictionary structure. This makes it easy to fetch calculated values, such as full_name, age, etc. In one respect, you could consider these helper functions, but I usually think of them as smart accessors - you store the minimal data necessary and calculate more common derived values on the fly (or you cache them in the rare chance it's worthwhile to do so). Andrea's suggestion (pre-calculating values in the after_find method) makes sense, but it assumes that the value is always worth calculating and storing after a lookup. (Perhaps you don't always need the value, or calculating it takes a long time). So what's the recommended convention for CakePHP for handling this stuff? Better yet, what do some of you who are veterans with the framework do? I could imagine it could be a helper class available to views where the input is the map of values. I could imagine something like QRCC suggests where its a method (static?) on the Model. Still, none of this feels right. I'm looking for something elegant and hope someone out there has already worked through this as a design issue. Thanks, skylar --~--~-~--~~~---~--~~ 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: Any truth to charge of 'thousands of db queries' ?
Yes, by default cakephp does make a lot of database queries if you have a lot of model associations. Thousands? Hmm... not really that I've seen.. but still more than one would hope for (for me sometimes between 40 and 120 per page, although all of them would take 0 ms each). Having said that, there are ways to minimise this by optimising your find calls, and only requesting the data that you need with the awesome Containable behaviour. I would also like to say that cake's database layer has undergone a bit of optimisation in the past year and queries are a lot more efficient and therefore less queries needed than what it used to be. Cheers, Adam On Oct 5, 8:53 pm, EastGhostCom [EMAIL PROTECTED] wrote: Some months ago I read an anti-cake / fear mongering message, something about how cakephp routinely makes thousands of database queries to accomplish typical, regular actions. Guess what? Fear was mongered. Not trying to monger more fear, just wondering (1) was there any truth to that, and (2) if so, what, if anything, is being done about it? --~--~-~--~~~---~--~~ 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: cannot inherit from undefined class appcontroller
If you have beforeFilter() method in your GroupsController (extending AppController), do you call parent::beforeFilter() from it? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cannot inherit from undefined class appcontroller
I found this thread in the group: http://groups.google.com/group/cake-php/browse_thread/thread/cf73faa906a7265d/844a8cfc17aadf36?hl=enlnk=stq=Cannot+inherit+from+undefined+class+appcontroller#844a8cfc17aadf36 It does not appear to have a resolution. 2-1/2 years later, I am having the same issue while working through the AclComponent tutorial with the following code. /blog/app/app_controller.php: class AppController extends Controller { var $components = array('Auth','Acl'); function beforeFilter() { //Configure AuthComponent $this-Auth-authorize = 'actions'; $this-Auth-loginAction = array('controller' = 'users', 'action' = 'login'); $this-Auth-logoutRedirect = array('controller' = 'users', 'action' = 'login'); $this-Auth-loginRedirect = array('controller' = 'posts', 'action' = 'add'); } } I get the subject error when I try to access the group index action. Is there something obvious that I am doing wrong? rogwei --~--~-~--~~~---~--~~ 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: $this-
Hey Jon, Thanks very much for the link. I must say I'm very frustrated with the way the articles I find explain this. Is there nowhere I can find a list of $this- means/does whatever it means/does, etc? Maybe also a list of rules like variables are local to the method until...? Thanks again for your help. -Matt On Sep 21, 7:32 am, Jon Bennett [EMAIL PROTECTED] wrote: hi Matt, What does $this- do? Is there a specific meaning to $this and to the - symbol? http://www.devarticles.com/c/a/PHP/Object-Oriented-Programming-in-PHP/ jb -- jon bennett w:http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: $this-
mattocrocop wrote: Hey Jon, Thanks very much for the link. I must say I'm very frustrated with the way the articles I find explain this. Is there nowhere I can find a list of $this- means/does whatever it means/does, etc? Maybe also a list of rules like variables are local to the method until...? Thanks again for your help. -Matt Hi Matt, Take a look at the PHP manual for their definition of the $this pseudo-variable: http://ca3.php.net/manual/en/language.oop5.basic.php --~--~-~--~~~---~--~~ 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: Any truth to charge of 'thousands of db queries' ?
As Adam said, it is an unrealistic claim to say cake makes thousands of queries to do something routine. In addition, you always have full control over the generated queries either by enforcing JOINs with on-the-fly model binding, or by using Containable to limit the amount of returned data. On Oct 5, 6:53 am, EastGhostCom [EMAIL PROTECTED] wrote: Some months ago I read an anti-cake / fear mongering message, something about how cakephp routinely makes thousands of database queries to accomplish typical, regular actions. Guess what? Fear was mongered. Not trying to monger more fear, just wondering (1) was there any truth to that, and (2) if so, what, if anything, is being done about it? --~--~-~--~~~---~--~~ 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: how i use the cakephp session in vendor module?
make sure the session name (cookie name) is the same in both apps. see core.php On Oct 5, 1:02 am, Nasir Khan Jr [EMAIL PROTECTED] wrote: hi, i am new in cakephp. i have a problem in using the third party module e;g. chat i want to use the cakephp session in this module when i print the session variable in cakephp controller it shows the value but in third party modules i am not able to get the session variables y pleas any one can help me? --~--~-~--~~~---~--~~ 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: $this-
Hi, I'm new to php, OO (object oriented) programming, software development, and to the web in general. I did learn some algebra last year, though. I got 68% in my final exam. Whew, it was hard. This morning, my older sister showed me how to create my very own Google account. It sure was challenging choosing that password. Now I feel confident about developing serious applications using cakephp. There's just one thing I don't know, but after that, I'm sure everything will go smoothly, 'cause, well, I know I have a gut feel for programming. What does $this- mean? I know, you're probably going to tell me I haven't looked hard enough for the answer. But, we have a Webster's Dictionary in our house, and I looked up $this- but couldn't find it. Honest. So there must be something wrong with cakePHP. And the cookbook, it's awful. I read it from beginning to end, didn't understand a thing, and still didn't find any explanation of $this-. By the way, is php a compiled language? (heh, don't really know what that means yet, but it is on the syllabus for the computer science 101 course I am registered in next semester). What is faster to use in production systems, Smalltalk or cakephp? Is Smalltalk a better framework? I think so, I've heard it's more object oriented. Anyways, I don't find this cakephp group very informative at all. Close to 10,000 developers and no one talks about what $this- means. :-)) LOL --~--~-~--~~~---~--~~ 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: Extend running blog example: user makes posts with custom set of tags
$this-set('tags', $this-User-Tag-find('list', array('conditions'=array('Tag.user_id'=$this-Auth-user('id')... On Oct 4, 1:44 pm, GrandiJoos [EMAIL PROTECTED] wrote: Hi all, I ran in a HABTM problem which I'll try to translate to the running blog example used in the CakePHP documentation. Imagine a blog with multiple authors (users) who can post articles and add tags to posts. Now assume that each author has its own set of tags, this would result in the following relationships: User HasMany Posts User HasMany Tags Posts HABTM Tags (and vice versa). Now, when a user creates a post I want to only show his collection of tags, how would I do that? Can I access the userId stored in the session from the model and include it in the HABTM conditional field? Or is there another (neat) trick necessary? Any help is appreciated! GrandiJoos --~--~-~--~~~---~--~~ 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: $this-
Hi, I'm new to php, OO (object oriented) programming, software development, and to the web in general. I did learn some algebra last year, though. I got 68% in my final exam. Whew, it was hard. This morning, my older sister showed me how to create my very own Google account. It sure was challenging choosing that password. Now I feel confident about developing serious applications using cakephp. There's just one thing I don't know, but after that, I'm sure everything will go smoothly, 'cause, well, I know I have a gut feel for programming. What does $this- mean? I know, you're probably going to tell me I haven't looked hard enough for the answer. But, we have a Webster's Dictionary in our house, and I looked up $this- but couldn't find it. Honest. So there must be something wrong with cakePHP. And the cookbook, it's awful. I read it from beginning to end, didn't understand a thing, and still didn't find any explanation of $this-. By the way, is php a compiled language? (heh, don't really know what that means yet, but it is on the syllabus for the computer science 101 course I am registered in next semester). What is faster to use in production systems, Smalltalk or cakephp? Is Smalltalk a better framework? I think so, I've heard it's more object oriented. Anyways, I don't find this cakephp group very informative at all. Close to 10,000 developers and no one talks about what $this- means. :-)) LOL lol - now that's what I call sarcasm! :) -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
css parsing stripping background-image tags from css
Hi, I've been playing with cakephp for a litle bit and its taken me a while to figure this out. cake seems to be stripping out tags from my css files. My mod_rewrite is working and my paths are correct. I'm running on winxp and assumed it was some kind of permissions problem. I've been stumped with this for 2 days and I've just thought to look at cakes output in firebug which is showing my css file without (*some) of the background-image tags. Thats the strange thing because the last couple are still in there. My css styles have been reshuffled into alphabetic order and some removed. Is there some kind of css parser in cake I can check or alter. I'm relatively new to cake but not a complete. Any help or advice would be appreciated. Thanks, P --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Conventions regarding people and Person
Hello everybody. I have a question regarding the convention within the CakePHP manual. At point 2.4.4 in the Manual for version 1.2.x it says that when you create a Model class called Person, the corresponding table in the database is/should be people. Now, it does state earlier in the manual that the database table name has to be the plural of the model class...but does CakePHP really work this way? Should it not be persons? I am not speaking from a What is correct in the English dictionary? type of way, rather from a programming view. Did CakePHP take all the plurals available in the dictionary and made sure to recognize: man - men mouse - mice person - people and every other plural form that does not abide by the rules? Anyhow, awaiting an answer about this. Cheers. --~--~-~--~~~---~--~~ 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: Conventions regarding people and Person
On Sun, Oct 5, 2008 at 9:47 AM, Sentinel [EMAIL PROTECTED] wrote: Hello everybody. I have a question regarding the convention within the CakePHP manual. At point 2.4.4 in the Manual for version 1.2.x it says that when you create a Model class called Person, the corresponding table in the database is/should be people. Now, it does state earlier in the manual that the database table name has to be the plural of the model class...but does CakePHP really work this way? Should it not be persons? I am not speaking from a What is correct in the English dictionary? type of way, rather from a programming view. Did CakePHP take all the plurals available in the dictionary and made sure to recognize: man - men mouse - mice person - people and every other plural form that does not abide by the rules? It does a lot of them http://api.cakephp.org/inflector_8php-source.html#l00077 and you can make more to add yourself Sam D --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Error: RedirectController could not be found.
Hi everybody, I'm going through a book called CakePHP Application Development and I thought I was doing okay. Then, without changing anything deliberately all of my pages are showing errors. Here are the errors: Error: RedirectController could not be found. Error: Create the class RedirectController below in file: app/ controllers/redirect_controller.php ?php class RedirectController extends AppController { var $name = 'Redirect'; } ? I now have a similar error (but with different missing controllers) on all of my pages. Has anybody come across this error before, and can anyone suggest a cause or remedy? Cheers, Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
CakePHP 1.2 RC3 - Problem with alphaNumeric validation
Hello, I upgraded my project from RC2 to RC3 today, and all went smoothly except for 1 area, validation. I have a User model, with the following validation: (a sample) var $validate = array( 'first_name' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = 'Your name can only contain letters.', ), 'between' = array( 'rule' = array('between', 1, 15), 'message' = 'You must supply your first name', 'required' = true ) ), 'last_name' = array( 'alphanumeric' = array( 'rule' = 'alphaNumeric', 'message' = 'Your name can only contain letters.', ), 'between' = array( 'rule' = array('between', 1, 15), 'message' = 'You must supply your last name', 'required' = true ) ) ); In CakePHP 1.2 RC3 both first_name and last_name fail to validate with valid values (or any value infact). I've traced this down to the regex in /cake/lib/validations.php, around line 170. My development machine, OS-X, PHP 5.25 this issue does not occur. On the server, CentOS, PHP 5.1.6 this does occur. If this is a setting in PHP, or a known issue with PHP 5.1.6 please let me know. James --~--~-~--~~~---~--~~ 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: Does calling model methods from elements break MVC pattern?
First of all, i must admit that this discussion is becoming very interesting, because i often find myself thinking if the way i'm doing something with CakePHP is actually the right way. My suggestion in using the after_find was just an example of a restricted case, but I think that it's not the true correct way to do things (because there could be a lot of situations in which we cannot apply that, and there are also many cases in which that solution is not efficient at all). I think that the fact that the Model Classes are often used as nothing more than an associative array, so sometimes i don't consider those real classes; that's why i prefer to let access them only from the controller. And i even think that making some shortcut from the view to the model, could create some problems with the routing/security/etc. because in that way there are actually ACTIONS not controlled (nor performed) by a CONTROLLER. For example if you then want to make any statistic on those performed actions where can you put your code then? in the model? in the view? ..there is not the controller. Bye, Andrea On Oct 5, 9:49 am, skylar [EMAIL PROTECTED] wrote: I'm really curious about this topic as well as it speaks to an aspect of the CakePHP Model class that has never really clicked with me. Andrea's example is perfect for explaining the point. In most MVC frameworks, when you retrieve data from storage (ram, db, file, etc), you usually get an instance of the model class itself, not a map/dictionary structure. This makes it easy to fetch calculated values, such as full_name, age, etc. In one respect, you could consider these helper functions, but I usually think of them as smart accessors - you store the minimal data necessary and calculate more common derived values on the fly (or you cache them in the rare chance it's worthwhile to do so). Andrea's suggestion (pre-calculating values in the after_find method) makes sense, but it assumes that the value is always worth calculating and storing after a lookup. (Perhaps you don't always need the value, or calculating it takes a long time). So what's the recommended convention for CakePHP for handling this stuff? Better yet, what do some of you who are veterans with the framework do? I could imagine it could be a helper class available to views where the input is the map of values. I could imagine something like QRCC suggests where its a method (static?) on the Model. Still, none of this feels right. I'm looking for something elegant and hope someone out there has already worked through this as a design issue. Thanks, skylar --~--~-~--~~~---~--~~ 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: Conventions regarding people and Person
Note that you can use the $useTable property in the model to explicitly define what table to use in case of doubt/ambiguity. http://manual.cakephp.org/view/436/useTable On Oct 5, 11:47 am, Sentinel [EMAIL PROTECTED] wrote: Hello everybody. I have a question regarding the convention within the CakePHP manual. At point 2.4.4 in the Manual for version 1.2.x it says that when you create a Model class called Person, the corresponding table in the database is/should be people. Now, it does state earlier in the manual that the database table name has to be the plural of the model class...but does CakePHP really work this way? Should it not be persons? I am not speaking from a What is correct in the English dictionary? type of way, rather from a programming view. Did CakePHP take all the plurals available in the dictionary and made sure to recognize: man - men mouse - mice person - people and every other plural form that does not abide by the rules? Anyhow, awaiting an answer about this. Cheers. --~--~-~--~~~---~--~~ 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: $this-
Thanks to all the guys who offered help. I found this great video series for beginners to OOP. http://www.killerphp.com/tutorials/object-oriented-php/index.php The last minute or so of Build Objects in PHP - Part I and the bulk of Part II offer a decent enough description of the meaning of $this, and the of -. Cheers, Matt --~--~-~--~~~---~--~~ 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: dealing with curly quotes
Hey Adam, thanks. Here's how I'm setup: core.php Configure::write('App.encoding', 'UTF-8') database.php (I don't see a place to specify UTF-8) MySQL utf8_general_ci default.ctp (head section) ?php echo $html-charset('UTF-8') ? Am I missing anything? When you say to make sure all of my code is utf8 compliant (eg string conversions), what do you mean? Can you be more specific? I think users of my site are entering curly quotes, which are saved to the db, then come out as garbage when displayed in HTML. -Ryan On Sep 30, 9:05 pm, Adam Royle [EMAIL PROTECTED] wrote: If your database is correctly setup as utf8, cakephp db settings as utf8 and your html is output as utf8, and make sure all of your code is utf8 compliant (eg string conversion, etc) then you shouldn't have any issues. Unless you just don't like the look of curly quotes? Cheers, Adam On Oct 1, 8:39 am, Ryan [EMAIL PROTECTED] wrote: I'm using a UTF-8 character set and the curly single and double quotes are causing some problems with my app. I have a couple of questions regarding the best way to deal with (eliminate) them: Allow the curly quotes to go into the database, but convert them to straight quotes before display? Or convert them into straight quotes before going into the database? And beyond that fundamental issue, what is the best way to convert from curly to straight? I've dealt with similar issues in some of my non-Cake PHP applications and am wondering if Cake has any built-in functionality for dealing. Thanks! --~--~-~--~~~---~--~~ 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: $this-
On Sun, Oct 5, 2008 at 10:38 PM, mattocrocop [EMAIL PROTECTED] wrote: Thanks to all the guys who offered help. I found this great video series for beginners to OOP. http://www.killerphp.com/tutorials/object-oriented-php/index.php The last minute or so of Build Objects in PHP - Part I and the bulk of Part II offer a decent enough description of the meaning of $this, and the of -. Thanks Matt for writing back. I'm sure beginners to OOP will appreciate the link. - Gonzalo --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
shell could not be loaded
I am trying to create and run my first shell script. When I try to run, I get this: class CloudShell extends Shell { var $uses = array('Item'); function main() { $this-out(test\n); } }Error: Class CloudShell could not be loaded What am I missing? Thanks! --~--~-~--~~~---~--~~ 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: dealing with curly quotes
class DATABASE_CONFIG { var $default = array( 'driver' = 'mysql', ... 'encoding' = 'utf8' ); } I forget to put that in on a regular basis and it always costs my a few minutes of debugging. ;-) Not sure why it's not in the default template. On 6 Oct 2008, at 10:24, Ryan wrote: Hey Adam, thanks. Here's how I'm setup: core.php Configure::write('App.encoding', 'UTF-8') database.php (I don't see a place to specify UTF-8) MySQL utf8_general_ci default.ctp (head section) ?php echo $html-charset('UTF-8') ? Am I missing anything? When you say to make sure all of my code is utf8 compliant (eg string conversions), what do you mean? Can you be more specific? I think users of my site are entering curly quotes, which are saved to the db, then come out as garbage when displayed in HTML. -Ryan On Sep 30, 9:05 pm, Adam Royle [EMAIL PROTECTED] wrote: If your database is correctly setup as utf8, cakephp db settings as utf8 and your html is output as utf8, and make sure all of your code is utf8 compliant (eg string conversion, etc) then you shouldn't have any issues. Unless you just don't like the look of curly quotes? Cheers, Adam On Oct 1, 8:39 am, Ryan [EMAIL PROTECTED] wrote: I'm using a UTF-8 character set and the curly single and double quotes are causing some problems with my app. I have a couple of questions regarding the best way to deal with (eliminate) them: Allow the curly quotes to go into the database, but convert them to straight quotes before display? Or convert them into straight quotes before going into the database? And beyond that fundamental issue, what is the best way to convert from curly to straight? I've dealt with similar issues in some of my non-Cake PHP applications and am wondering if Cake has any built-in functionality for dealing. Thanks! --~--~-~--~~~---~--~~ 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: $this-
I too have battled with this, so went hunting I found this explanation that I think is fairly clear! $this explanation The $this pseudo-variable provides a mechanism for objects to refer to their own properties and methods. Outside of an object, there is a handle you can use to access its elements. Inside an object, there is no such handle, so you must fall back on $this. If you find $this confusing, try replacing it in your mind with the current instance when you encounter it in code. End - explanation You can access public object properties using the object operator '- '. So $en-type means the $type property of the Dictionary object referenced by $en. If you can access a property, it means that you can set and get its value. End HTH - Dave Porter On Oct 6, 9:29 am, Gonzalo Servat [EMAIL PROTECTED] wrote: On Sun, Oct 5, 2008 at 10:38 PM, mattocrocop [EMAIL PROTECTED] wrote: Thanks to all the guys who offered help. I found this great video series for beginners to OOP. http://www.killerphp.com/tutorials/object-oriented-php/index.php The last minute or so of Build Objects in PHP - Part I and the bulk of Part II offer a decent enough description of the meaning of $this, and the of -. Thanks Matt for writing back. I'm sure beginners to OOP will appreciate the link. - Gonzalo --~--~-~--~~~---~--~~ 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: $this-
Cool. Thanks guys! My problem with searching for the answers was really that I didn't know what I was looking for. I wasn't sure whether it was a feature of basic PHP, OOP, or CakePHP. I guess that the last time I looked at PHP in any detail was probably prior to PHP 5. Once again, thanks to everyone for your support. On Oct 5, 11:06 pm, Dave Porter [EMAIL PROTECTED] wrote: I too have battled with this, so went hunting I found this explanation that I think is fairly clear! $this explanation The $this pseudo-variable provides a mechanism for objects to refer to their own properties and methods. Outside of an object, there is a handle you can use to access its elements. Inside an object, there is no such handle, so you must fall back on $this. If you find $this confusing, try replacing it in your mind with the current instance when you encounter it in code. End - explanation You can access public object properties using the object operator '-'. So $en-type means the $type property of the Dictionary object referenced by $en. If you can access a property, it means that you can set and get its value. End HTH - Dave Porter On Oct 6, 9:29 am, Gonzalo Servat [EMAIL PROTECTED] wrote: On Sun, Oct 5, 2008 at 10:38 PM, mattocrocop [EMAIL PROTECTED] wrote: Thanks to all the guys who offered help. I found this great video series for beginners to OOP. http://www.killerphp.com/tutorials/object-oriented-php/index.php The last minute or so of Build Objects in PHP - Part I and the bulk of Part II offer a decent enough description of the meaning of $this, and the of -. Thanks Matt for writing back. I'm sure beginners to OOP will appreciate the link. - Gonzalo --~--~-~--~~~---~--~~ 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: $this-
The very basics in simple language: An object is grouping variables and functions together. class MyObject { var $myObjectVariable = 12; function myObjectFunction() { // does something } } You can move a bunch of functions and variables around in one package without worrying about naming conflicts with other variables or function names, and can reliably access those variables inside the object since they're guaranteed to be packaged together. $obj = new MyObject(); Now $obj has all the stuff I declared above in class MyObject. To access all that stuff, you use -. $obj-myObjectVariable; // = 12 $obj-myObjectFunction(); // does something The question that remains is, how do you access $obj-myObjectVariable from within the object itself (i.e. from the line // does something above)? The answer: $this. class MyObject { var $myObjectVariable = 12; function myObjectFunction() { $this-myObjectVariable;// refers to 12 above } } Just felt like posting that here... ;) On 6 Oct 2008, at 12:19, mattocrocop wrote: Cool. Thanks guys! My problem with searching for the answers was really that I didn't know what I was looking for. I wasn't sure whether it was a feature of basic PHP, OOP, or CakePHP. I guess that the last time I looked at PHP in any detail was probably prior to PHP 5. Once again, thanks to everyone for your support. On Oct 5, 11:06 pm, Dave Porter [EMAIL PROTECTED] wrote: I too have battled with this, so went hunting I found this explanation that I think is fairly clear! $this explanation The $this pseudo-variable provides a mechanism for objects to refer to their own properties and methods. Outside of an object, there is a handle you can use to access its elements. Inside an object, there is no such handle, so you must fall back on $this. If you find $this confusing, try replacing it in your mind with the current instance when you encounter it in code. End - explanation You can access public object properties using the object operator '- '. So $en-type means the $type property of the Dictionary object referenced by $en. If you can access a property, it means that you can set and get its value. End HTH - Dave Porter On Oct 6, 9:29 am, Gonzalo Servat [EMAIL PROTECTED] wrote: On Sun, Oct 5, 2008 at 10:38 PM, mattocrocop [EMAIL PROTECTED] wrote: Thanks to all the guys who offered help. I found this great video series for beginners to OOP. http://www.killerphp.com/tutorials/object-oriented-php/index.php The last minute or so of Build Objects in PHP - Part I and the bulk of Part II offer a decent enough description of the meaning of $this, and the of -. Thanks Matt for writing back. I'm sure beginners to OOP will appreciate the link. - Gonzalo --~--~-~--~~~---~--~~ 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: css parsing stripping background-image tags from css
Are you using CSS compression? If so, if the CSS syntax is invalid Cake might strip it out accidentally when removing comments etc. And the usual: Check caching. Maybe Cake or your webserver is just serving an old copy. Make sure you are looking at the same two files (editing A while actually B is included). On 6 Oct 2008, at 00:33, paulinthought wrote: Hi, I've been playing with cakephp for a litle bit and its taken me a while to figure this out. cake seems to be stripping out tags from my css files. My mod_rewrite is working and my paths are correct. I'm running on winxp and assumed it was some kind of permissions problem. I've been stumped with this for 2 days and I've just thought to look at cakes output in firebug which is showing my css file without (*some) of the background-image tags. Thats the strange thing because the last couple are still in there. My css styles have been reshuffled into alphabetic order and some removed. Is there some kind of css parser in cake I can check or alter. I'm relatively new to cake but not a complete. Any help or advice would be appreciated. Thanks, P --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Javascript causing Ajax form to submit, but not all ajaxy like I want
I didn't know how else to describe it. Here's the code: ? echo $ajax-form('addComment', 'post', array( 'model' = 'Comment', 'url' = array('controller' = 'comments', 'action' ='add'), 'update' = 'pureGenius')); //echo $form-input('comment', array('rows' = '3')); ? script type=javascript var flag = false; /script textarea name=data[Comment][comment] onKeyDown=if(event.keyCode == 13 flag) { submit(); } if(event.keyCode == 16) { flag = true; } onKeyUp=if(event.keyCode == 16) { flag = false; } style=width:100%; height:100px; id=CommentComment /textarea ? echo $form-end('Talk'); ? So basically I want it when someone types Shift+Enter in the text box it submits the form. If I use the submit button, the form submits all ajaxy in the proper way. However if I use the Shift+Enter method, the form submits, but not in the good ajax way, it reloads the page. Is there a seperate submit call for an ajax form? Also, I find that its impossible to name a form. The 'addComment' doesn't work. Neither does putting it in the array options. Anyone else find this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---