Querying across multiple tables in CakePHP 3.x ORM
I have three tables *Countries, Cities* and *Addresses*. Their relationship is Countries hasMany Cities, Cities hasMany Addresses. So Its something like this Countries-Cities-Addresses. If I want to get all addresses in a certain city I can do it like this $this-paginate = [ 'contain' = ['Cities'] ]; $this-set('addresses', $this-paginate($this-Addresses)); If I want to get all Cities in a certain Country I can do like that as well. *What I want is I want to get all Addresses in a Certain Country. *If there's new way by modifying above code or using ORM it would be great. Note: Addresses *does not* contain foreign key for Countries, instead its in the Cities. Possible query would be: SELECT a.*, c.* FROM countries a LEFT JOIN cities b ON a.id=b.country_id LEFT JOIN addresses c ON b.id=c.city_id -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
CakePhp doesn't read the script
I updated my apache and php on local server and my project on cake stoped working. Now it looks like on the picture https://lh5.googleusercontent.com/-lMpm_kBoAAw/UjdnyAgRjgI/FUE/f2I4QgTZ_1A/s1600/%D0%BA%D0%B5%D0%B9%D0%BA.png Please HELP is extremely needed! -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
cakePHP File Download was not found or not readable
I've been struggling now for an hour trying to fix this. I used this to download file from app/uploads/directory. It says the directory not found or not readable. Yet i checked it and it was there also the file using $file['File']['filename']. I want to know what I am missing here.? $file = $this-File-findById($id); $extension = pathinfo($file['File']['filename'],PATHINFO_EXTENSION); $this-response-file('uploads'.DS, array('download' = true, 'id' = $file['File']['filename'], 'name' = $file['File']['filename'] ) ); $this-response-type($extension); return $this-response; -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: $this-redirect not working
Without the redirect Cake should take you back to the 'instructions' view. Have you tried removing the redirect line to see what happens (assuming the instructions action you have here is in the instructions controller)? George On Sat, Mar 10, 2012 at 8:54 PM, Brian Bowler bbowle...@gmail.com wrote: So I have this function where the user can add the weight to materials and save them. However after the updateAll, $this-redirect doesn't work at all and the result shows up with a blank page with nothing in the source. In an ideal world I would have it redirect to a different page but at a minimum I would like it to go back to the page where they entered in the weights. public function instructions($id = null) { $instructions = $this-Formula-findFormula($id); $count = count($instructions); $this-set(array('instructions' = $instructions, 'count' = $count, 'formulaId' = $id)); if(!empty($this-data)) { $count = count($this-request-data); for($i = 0; $i = $count; $i++) { $this-Formula-updateAll( array('Formula.weight' = $this-request-data['Formula'][$i]['weight']), array('Formula.id' = $this-request-data['Formula'][$i]['id']) ); } } $this-redirect(array('controller' = 'instructions', 'action' = 'instructions', $id)); } I have no idea what causes this. Any help is much appreciated, even if its just telling me where in the manual to read up on it. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Hot out of the oven CakePHP 1.3 alpha
Great work guys! On Nov 4, 4:28 pm, mark_story mark.st...@gmail.com wrote: The CakePHP development team is happy to release the alpha build of CakePHP 1.3. We've been hard at work improving upon the already great 1.2 and implementing new features to ease development and increase the flexibility of CakePHP. There have been a number of changes to existing features and its recommended that you review the migration guide[1] for changes in existing classes and features. Also checkout the new features guides[2] for the new features introduced in 1.3. As the 1.3 code branch stabilizes, methods that are currently deprecated and generating errors will be removed. It is therefore important to update the necessary methods to their new names. If you would like to help with the ongoing development of 1.3, you can do so in a number of ways. Firstly filing clear and concise tickets for any issues with new or existing code helps get the issues resolved. You can also contribute by forking the CakePHP project on code.cakephp.org and implementing features and test cases in your forks. This speeds up development as cherry picking commits is faster and easier than applying patches. The future roadmap places CakePHP 1.3, as a stepping stone towards the also in development CakePHP 2.0 branch which will feature a mostly backwards compatible API. The CakePHP 2.0 branch can be found athttp://code.cakephp.org/cakephp2 Finally, we'd like to thank the community for their ongoing support and contributions in making CakePHP as great as it is. Download a packaged release, [3] Read the changelog [4] [1]http://code.cakephp.org/wiki/1.3/migration-guide [2]http://code.cakephp.org/wiki/1.3/new-features [3]http://cakeforge.org/frs/?group_id=23release_id=452 [4]http://code.cakephp.org/wiki/changelog/1_3_0-alpha --~--~-~--~~~---~--~~ 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: Odd code in sanitize core lib?
I thought this was the case too (I use Consolas fwiw), so I pasted the code into an empty text editor (TextWrangler) and did a search for '!', and it returned two results. What font are you using to view the code, making the search and replace strings different? As far as I can tell, the search and replace strings are identical. I'm guessing it's some sort of testing code that wasn't cleaned up during the refactoring process...? I don't know. But yeah -- this isn't a ground-breaking drop-what-you're-doing kind of thing, just out of curiosity I was just wondering why that's there. On Oct 29, 11:47 pm, Martin Westin martin.westin...@gmail.com wrote: I am just guessing here but couldn't it be replacing looks like an exclamation but is really far out into outfer space with a normal exclamation? Using a bad font and the code look different. On Oct 29, 7:32 am, Miles J mileswjohn...@gmail.com wrote: I thought you were lying so I checked, and haha it is there. Im curious on this as well. On Oct 28, 8:51 pm, George H acher...@gmail.com wrote: Hi guys, I've been debugging my controller that is using Sanitize and I had a peek inside the CakePHP Sanitize core lib file, where I found something odd. Is it possible if someone could explain to me (I'm just genuinely curious) the reasoning behind line 223 in /cake/libs/sanitize.php (version 1.2.5)? $data = str_replace(', ', str_replace(!, !, $data)); From what I can tell, this line is replacing ! chars with !, and then replacing ' chars with '. I've done some checks and the search and replace strings are exactly the same. As I mentioned, I am genuinely curious (probably more curious if I am lost my marbles or not and maybe I'm seeing things), so any core devs out there please do not see this as a personal attack on you, or your intelligence, or ability to cut good code, etc etc. Cheers, -- George --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Odd code in sanitize core lib?
Hi guys, I've been debugging my controller that is using Sanitize and I had a peek inside the CakePHP Sanitize core lib file, where I found something odd. Is it possible if someone could explain to me (I'm just genuinely curious) the reasoning behind line 223 in /cake/libs/sanitize.php (version 1.2.5)? $data = str_replace(', ', str_replace(!, !, $data)); From what I can tell, this line is replacing ! chars with !, and then replacing ' chars with '. I've done some checks and the search and replace strings are exactly the same. As I mentioned, I am genuinely curious (probably more curious if I am lost my marbles or not and maybe I'm seeing things), so any core devs out there please do not see this as a personal attack on you, or your intelligence, or ability to cut good code, etc etc. Cheers, -- George --~--~-~--~~~---~--~~ 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: Release: CakePHP 1.2.5
Hi Mark, Thanks for replying. I'm in no way mad at all -- after all it's a version number, I was just annoyed ('miffed' means annoyed) by the silence from the devs. I was mostly confused about trusting whether 1.2.5 was in fact 1.2.5, because as I stated earlier, if the version number wasn't committed properly, maybe other fixes haven't either. I have your word that nothing else is missing, so I'll take it. Besides, if there is a problem I guess I could always wait until 1.2.6! Yes, this was a slip up, but it's rather minor in my books, and I still love and use CakePHP every day, so keep up the good work Mark et al. -- George On Oct 2, 12:55 pm, mark_story mark.st...@gmail.com wrote: George, Sorry to hear you're miffed, but I made a mistake in packaging 1.2.5 so the version number printed when running shells reads 1.2.4.8284. While the VERSION.txt reads 1.2.5. So if you want to be mad at someone be mad at me. As for other things missing, there is nothing that I'm aware of. As the version number changes are the last changes made before packaging. I'll try to do better in the future, sorry for all the confusion and anguish this has caused you. -Mark On Oct 1, 9:07 pm, George H acher...@gmail.com wrote: I'm a little miffed that there's no word from any developers about the issue above -- either through here, twitter or CakePHP Bakery. My main concern is that the release notes for this version state that a change has been made (the version number for example) but the download package doesn't have that change applied – if this particular change hasn't been delivered, what else is missing from this version? I know it's just a version number but it makes me think what else is missing from 1.2.5 that should be there according to the release notes. On Sep 15, 10:46 am, euromark (munich) dereurom...@googlemail.com wrote: the nightly build does not have the date problems so i guess this was an error on building the official release the version number is still 1.2.4 in the nightly as well though On 15 Sep., 01:45, frsp forpo...@gmail.com wrote: Yes, it is a bit strange * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ and return $config['Cake.version'] = '1.2.4.8284'; for cake 1.2.5 Any comments from developers? On Sep 10, 5:53 am, George H acher...@gmail.com wrote: Good going with the release of 1.2.5! I've already downloaded and installed it. However, I noticed that the version reported is still 1.2.4.8284. Are you sure this is a clean commit to the code base? Commit [e693e881e05dba168f49d14ab657dbff2b2f9c88] in the changelog says that the version number was updated, but this doesn't seem to be the case for me. Also, the $ macros in each PHP script in the top comments (stuff like $Id$ and $Revision$) are all blank / default, and not the actual data that should be in there. FWIW, I downloaded the .tar.bz2 distribution from here:http://cakeforge.org/frs/download.php/733/cake_1.2.5.tar.bz2 --~--~-~--~~~---~--~~ 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: Release: CakePHP 1.2.5
I'm a little miffed that there's no word from any developers about the issue above -- either through here, twitter or CakePHP Bakery. My main concern is that the release notes for this version state that a change has been made (the version number for example) but the download package doesn't have that change applied – if this particular change hasn't been delivered, what else is missing from this version? I know it's just a version number but it makes me think what else is missing from 1.2.5 that should be there according to the release notes. On Sep 15, 10:46 am, euromark (munich) dereurom...@googlemail.com wrote: the nightly build does not have the date problems so i guess this was an error on building the official release the version number is still 1.2.4 in the nightly as well though On 15 Sep., 01:45, frsp forpo...@gmail.com wrote: Yes, it is a bit strange * @version $Revision$ * @modifiedby$LastChangedBy$ * @lastmodified $Date$ and return $config['Cake.version'] = '1.2.4.8284'; for cake 1.2.5 Any comments from developers? On Sep 10, 5:53 am, George H acher...@gmail.com wrote: Good going with the release of 1.2.5! I've already downloaded and installed it. However, I noticed that the version reported is still 1.2.4.8284. Are you sure this is a clean commit to the code base? Commit [e693e881e05dba168f49d14ab657dbff2b2f9c88] in the changelog says that the version number was updated, but this doesn't seem to be the case for me. Also, the $ macros in each PHP script in the top comments (stuff like $Id$ and $Revision$) are all blank / default, and not the actual data that should be in there. FWIW, I downloaded the .tar.bz2 distribution from here:http://cakeforge.org/frs/download.php/733/cake_1.2.5.tar.bz2 --~--~-~--~~~---~--~~ 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: find conditions comparing two fields
Nice, that worked. Thanks! On Sep 15, 5:56 pm, brian bally.z...@gmail.com wrote: Try: $conditions = array('User.id = User.parent_id'); On Tue, Sep 15, 2009 at 5:51 PM, George geo...@hakumei.net wrote: This seems like a simple thing to do, but I haven't been able to figure out how to write the find conditions array to do it. Basically, I want to run a query where I check whether one field in the record equals another field in the same record. A simple illustration in SQL: SELECT * FROM users as User WHERE User.id = User.parent_id If you make a conditions array like: $conditions = array('User.id' = 'User.parent_id'); cakePHP generates the SQL as SELECT * FROM users as User WHERE User.id = 'User.parent_id' and it fails on a data conversion error (sql fails trying to convert the varchar value 'User.parent_id' to an int). I couldn't find anything on this in the manual, but surely there's a workaround using the cakePHP find conventions rather than resorting to just writing the query right? Thanks for any help you can provide. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
find conditions comparing two fields
This seems like a simple thing to do, but I haven't been able to figure out how to write the find conditions array to do it. Basically, I want to run a query where I check whether one field in the record equals another field in the same record. A simple illustration in SQL: SELECT * FROM users as User WHERE User.id = User.parent_id If you make a conditions array like: $conditions = array('User.id' = 'User.parent_id'); cakePHP generates the SQL as SELECT * FROM users as User WHERE User.id = 'User.parent_id' and it fails on a data conversion error (sql fails trying to convert the varchar value 'User.parent_id' to an int). I couldn't find anything on this in the manual, but surely there's a workaround using the cakePHP find conventions rather than resorting to just writing the query right? Thanks for any help you can provide. --~--~-~--~~~---~--~~ 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: Release: CakePHP 1.2.5
Good going with the release of 1.2.5! I've already downloaded and installed it. However, I noticed that the version reported is still 1.2.4.8284. Are you sure this is a clean commit to the code base? Commit [e693e881e05dba168f49d14ab657dbff2b2f9c88] in the changelog says that the version number was updated, but this doesn't seem to be the case for me. Also, the $ macros in each PHP script in the top comments (stuff like $Id$ and $Revision$) are all blank / default, and not the actual data that should be in there. FWIW, I downloaded the .tar.bz2 distribution from here: http://cakeforge.org/frs/download.php/733/cake_1.2.5.tar.bz2 On Sep 10, 1:54 am, mark_story mark.st...@gmail.com wrote: The CakePHP development team is happy to announce CakePHP 1.2.5[1]. 1.2.5 is a bug fix release of the latest stable branch. Check the changelog[2] for all the changes. CakePHP 1.2.5 Includes almost 40 commits and more than 20 fixes. Furthermore, due to popular demand CakePHP 1.2.5 is compatible with PHP 5.3 and includes fixes to suppress the deprecation messages. See the changelog[2] for a complete list of changes and bugs fixed. The 1.3 branch has seen continued progress and there will be another development release sometime soon. If you would like to contribute to the development of 1.3 and hasten its arrival, there is a more detailed summary of things to do[3] And as always, thank you for helping us make a great framework. [1]http://cakeforge.org/frs/?group_id=23release_id=449 [2]http://code.cakephp.org/wiki/changelog/1_2_x_x [3]http://code.cakephp.org/wiki/RFCs/1-3-todo-list --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
IE7 form submission with array fields
I'm not sure this is specific to cakePHP, but has anyone encountered an issue with IE7 where it truncates an array-like form field? Basically, I have a dynamic form using javascript that allows an arbitrary number of fields, all named the same (prices.0.price, prices. 1.price, etc). Whenever I submit the form in IE7, it seems to only take the first and last field, and drops everything in between. So if I have 4 fields, $this-data will show up with only fields 0 and 3. Is there a fix for this that anyone knows about or has anyone found a way around it? FF, IE8, Chrome, Safari all work just fine. --~--~-~--~~~---~--~~ 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: Database / Relationship question (habtm)
You really need to think of the three entities separately first, and decide how they should be related before you go on and start coding. Making an ER diagram is usually very helpful. (look it up if you don't know what an ER diagram is...you'll find a ton of info). It sounds like your app is like a bulletin board. In that case, off the top of my head, how I'd first flesh it out follows: Categories can have many topics Topics belong to a category Profiles can have many topics (a user can start many topics) Topics belong to many profiles (topics are written to by more than one user) Categories and Profiles don't need a relationship; their relation can be inferred by the other relationships if need be. I guess if you REALLY wanted to know who created a category though, you'd have Categories belong to Profiles and Profiles Have Many Categories, but I won't include that. So you'd have: Categories Have Many Topics Topics Belong To Categories Profiles HABTM Topics And you'd need the tables: categories, topics, profiles, profiles_topics Now, if this was a BB, you'd also have posts. And Posts would belong to Topics (threads) and Topics would have many Posts. That's how I'd do it I guess. If your app is different from that though, then your relationships would possibly be different and you'd have to follow the previous post's advice and ask yourself those questions. I think an ER diagram will help you a lot to figure out what you want before you spend a lot of time coding in the wrong direction. On Jul 21, 10:06 am, ulterior ulteriordes...@gmail.com wrote: I'm somewhat new to cake, this is my second app and I'm having problems with relationships. The first app I created was pretty straightforward and I had a great time writing it in cake but my database skills aren't up to par with my php! Here goes: I have three tables that contain data which I want to relate, profiles, categories and topics. I created a categories_topics table with category_id and topic_id and that's just fine. However, I want to link the categories and topics to profiles so I created categories_topics_profiles which contains the category_topic_id (from the join table) and the profile_id (to link to the Profiles model) but it's giving me errors when I try to run a simple find. Is this the right way to build the tables or am I missing something? Any help would be GREATLY appreciated. Thanks, -Chris --~--~-~--~~~---~--~~ 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: Paginator sort() links not switching between asc and desc?
Great, this worked! Thanks! On Apr 17, 5:54 pm, dr. Hannibal Lecter lecter...@gmail.com wrote: Yup... https://trac.cakephp.org/ticket/6218 On Apr 17, 8:38 am, George H acher...@gmail.com wrote: Hi guys, I have a list of users displayed in my view in a table, and the resultset is parsed by Paginator. I am also echoing $paginator-sort () in my view. When I view the page the links work and they sort by the columns that I have specified in my code. But I thought that if I was to click on the same column again (eg. sorting by last logged in date) that it would sort in descending order, click again sort ascending, etc. It's not doing this – it just sticks to ascending order only. Is this the way it supposed to work? In the documentation (http:// api.cakephp.org/class/paginator-helper#method-PaginatorHelpersort) it says under return: string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified key the returned link will sort by 'desc'. I've taken this to interpret as the link is like a toggle, but in my case this isn't the case. You can see my code here:http://pastebin.com/f64b7e200 TIA. -- George --~--~-~--~~~---~--~~ 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: Paginator sort() links not switching between asc and desc?
Great, this worked! Thanks! On Apr 17, 5:54 pm, dr. Hannibal Lecter lecter...@gmail.com wrote: Yup... https://trac.cakephp.org/ticket/6218 On Apr 17, 8:38 am, George H acher...@gmail.com wrote: Hi guys, I have a list of users displayed in my view in a table, and the resultset is parsed by Paginator. I am also echoing $paginator-sort () in my view. When I view the page the links work and they sort by the columns that I have specified in my code. But I thought that if I was to click on the same column again (eg. sorting by last logged in date) that it would sort in descending order, click again sort ascending, etc. It's not doing this – it just sticks to ascending order only. Is this the way it supposed to work? In the documentation (http:// api.cakephp.org/class/paginator-helper#method-PaginatorHelpersort) it says under return: string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified key the returned link will sort by 'desc'. I've taken this to interpret as the link is like a toggle, but in my case this isn't the case. You can see my code here:http://pastebin.com/f64b7e200 TIA. -- George --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Paginator sort() links not switching between asc and desc?
Hi guys, I have a list of users displayed in my view in a table, and the resultset is parsed by Paginator. I am also echoing $paginator-sort () in my view. When I view the page the links work and they sort by the columns that I have specified in my code. But I thought that if I was to click on the same column again (eg. sorting by last logged in date) that it would sort in descending order, click again sort ascending, etc. It's not doing this – it just sticks to ascending order only. Is this the way it supposed to work? In the documentation (http:// api.cakephp.org/class/paginator-helper#method-PaginatorHelpersort) it says under return: string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified key the returned link will sort by 'desc'. I've taken this to interpret as the link is like a toggle, but in my case this isn't the case. You can see my code here: http://pastebin.com/f64b7e200 TIA. -- George --~--~-~--~~~---~--~~ 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: Offline version of the CakePHP manual.
Dardo, I'd be interested in that script too, if you could send me a copy that would be a great help Cheers George On Apr 5, 9:24 pm, Dardo Sordi Bogado dardoso...@gmail.com wrote: Dardo, if I could ask you to either send me the source or publish it, as it looks like a nice script to have for creating a pdf snapshot of the manual. Hope you don't take offence, Mike, but Dardo's version is just in a format that is more easy to read. I'll send you a copy of the source in a personal email, but I think that publishing its output is a derivative work and its forbidden by the cookbook license. So you will have to ask permission before doing anything with cookbook's content. Regards, - Dardo. --~--~-~--~~~---~--~~ 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: Defining Custom Association Queries - merging results fails
After considerable digging, I'm basically at the final root of this problem. finderQuery is correctly getting the records, but they are failing to actually be merged with the User model. This blog post (http:// www.visuallizard.com/wil/blog/210/) answered many of my questions, and some of the info there wouldn't be bad to add to the cakePHP documentation. After digging into the libs/model/datasources/dbo_source.php, I can see exactly where my relation is failing. In function __mergeAssociation, it fails right at the final conditional before it should merge each $merge[$row] into $data (line 994). My $merge array looks like this: array( [0] = Array ( [0] = Array ( [id] = 001 [name] = Person_1 ) ) [1] = Array ( [0] = Array ( [id] = 002 [name] = Person_1 ) ) [2] = Array ( [0] = Array ( [id] = 003 [name] = Person_1 ) ) It seems cake wants each row as an associative array, and mine are all numerical, for whatever reason. ($merge[n]['Salespeople'] instead of $merge[n][0]). I'm sure there is just some setting somewhere in my model probably that I'm missing, that would give each record a key instead of just 0. Does anyone know what I'm doing wrong? Here's the updated code I have for the $hasMany attribute that is causing all of this to run: var $hasMany = array('Salesperson' = array( 'className'='Salesperson', 'fields'=array ('Salesperson.id','Salesperson.name','Salesperson.email','Salesperson.phone','Salesperson.job_title'), 'foreignKey' = false, 'finderQuery' = 'SELECT [Salesperson].* FROM [nav_salespeople] AS [Salesperson] INNER JOIN [users] AS [User] ON RTRIM(REPLACE(LEFT([Salesperson].[email], CHARINDEX(\'@ \', [Salesperson].[email])), \'@\', \' \')) = [User].[username] WHERE [User].[id] IN ({$__cakeID__$})')); Shouldn't the fact that I have className set, put a key in that merge array? Or am I missing something? On Mar 24, 1:29 pm, George geo...@hakumei.net wrote: I have two tables I want to link together, but the association is a bit more complicated than it normally would be. One of the tables (users) is built specifically for cake, another is a table from a read- only database (salespeople). User.username = Salespeople.email (or xxx in x...@site.com). Users can have multiple Salespeople Salespeople will have one User So I have Users hasMany Salesperson Salespeople belongTo User In the hasMany association, you can assign the finderQuery condition to have a custom association. So I set that to get the all the Salespeople records with an email (minus @site.com) that matches User.username. The belongsTo association doesn't seem to provide the finderQuery condition, according to the documentation. I was looking around in the api to see if it really did but was just left out of the documentation but I couldn't find it. Furthermore, I'm getting errors with it in, so I assume it isn't allowed in a belongsTo association. So my question is has anyone done something similar or can help point me in the right direction? There really weren't any examples of using finderQuery in the documentation either, so I sort of guessed on the format the query itself should take. For completeness, my finderQuery in the User model is (using MS SQL Server): SELECT s.* FROM users u INNER JOIN salespeople s ON rtrim(replace(left(s.email, charindex('@', s.email)), '@', ' ')) = u.username where u.id = $this-id That would be the correct format for finderQuery to work, correct? Thanks for any help anyone can provide. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Defining Custom Association Queries
I have two tables I want to link together, but the association is a bit more complicated than it normally would be. One of the tables (users) is built specifically for cake, another is a table from a read- only database (salespeople). User.username = Salespeople.email (or xxx in x...@site.com). Users can have multiple Salespeople Salespeople will have one User So I have Users hasMany Salesperson Salespeople belongTo User In the hasMany association, you can assign the finderQuery condition to have a custom association. So I set that to get the all the Salespeople records with an email (minus @site.com) that matches User.username. The belongsTo association doesn't seem to provide the finderQuery condition, according to the documentation. I was looking around in the api to see if it really did but was just left out of the documentation but I couldn't find it. Furthermore, I'm getting errors with it in, so I assume it isn't allowed in a belongsTo association. So my question is has anyone done something similar or can help point me in the right direction? There really weren't any examples of using finderQuery in the documentation either, so I sort of guessed on the format the query itself should take. For completeness, my finderQuery in the User model is (using MS SQL Server): SELECT s.* FROM users u INNER JOIN salespeople s ON rtrim(replace(left(s.email, charindex('@', s.email)), '@', ' ')) = u.username where u.id = $this-id That would be the correct format for finderQuery to work, correct? Thanks for any help anyone can provide. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help on somewhat complicated model relationships
I have an application that is using three user models, from three datasources. One is specifically built for the application (User), one is LDAP-based (NetworkAccount), and the third is a static database (Salesperson), in that I can only read from it. I'm also using the ACL component, which complicates things a little more. Anyway, in the first database, I have my ACL tables and a user table. My problem is that the models based on the LDAP and static databases use a varchar username as their primary keys, and I can't change that. However ACL seems to require that the foreign keys in the aros table be integers. In my User model, I want to associate the corresponding models, but I can't figure out how to define the $hasOne conditions so that both the primary key in the base and the foreign key on the other side are custom. Basically if I set User.username to be the primary key, ACL fails because it can't convert the varchar to intergers in the aros table. Here is the pertinent info to make it more clear: Model User pkey = User.id (int) unique = User.username (varchar) Model NetworkAccount pkey = NetworkAccount.SAMAccountName (varchar) Model Salesperson pkey = Salesperson.Code (varchar) I know in the relation variables, you can specify a foreign key, which I have to do since neither of the other two tables have a user_id column. But can I specify the column in User that I want to match with? Obviously what I want to do is User.username = NetworkAccount.SAMAccountName and User.username = Salesperson.Code. But I haven't been able to figure out how to tell cake to use username instead of id for the relations. Hopefully that makes enough sense for someone to offer up an idea. If I can't use the built-in relation variables ($hasOne, $belongsTo), how would I go about writing custom queries that would automatically fire when a User object is created, to pull the info from the other two tables? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
String 'NULL' inserted instead of value NULL with ACL, MSSQL. Help?
I've been grinding away with ACL on a project, and I'm running into what appears to be a bug with the ACL code and dbo_mssql.php. Basically inserting new aco records fail due to cake generating incorrect SQL code (it puts single quotes around a NULL, thus inserting the string NULL, not NULL itself). I found this ticket (https://trac.cakephp.org/ticket/6024) in the trac which is basically exactly what's happening to me as well. It appears this hasn't been fixed in the latest nightly though, and I was wondering if anyone had an idea on how to apply a fix until the bug has been resolved. I also found an older reported bug that appears to be the same thing (https:// trac.cakephp.org/ticket/5381). I've been digging in libs/model/datasources/dbo/dbo_mssql.php, and libs/model/db_acl.php, but haven't been able to see where the quotes are being applied to the NULL value. My guess is there just needs to be an extra conditional to check for a null value and not apply quotes in that case. If anyone knows where this can be resolved, that would be awesome. --~--~-~--~~~---~--~~ 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: String 'NULL' inserted instead of value NULL with ACL, MSSQL. Help?
I found what so far seems like a temporary fix for this issue. It's probably not ideal, but the only drawback I think would be if you wanted to actually insert the string 'NULL', you can't after this fix. On line 278 in cake/libs/model/datasources/dbo/dbo_mssql.php, change: if (in_array($column, array('integer', 'float', 'binary')) is_numeric($data)) { to if ((in_array($column, array('integer', 'float', 'binary')) is_numeric($data)) || $data == 'NULL') { Now, if $data is NULL, it will get caught in this conditional and return without enclosing single quotes. I suppose you could change the last part to strtolower($data) == 'null' to catch any form of NULL instead. On Mar 11, 9:04 am, George geo...@hakumei.net wrote: I've been grinding away with ACL on a project, and I'm running into what appears to be a bug with the ACL code and dbo_mssql.php. Basically inserting new aco records fail due to cake generating incorrect SQL code (it puts single quotes around a NULL, thus inserting the string NULL, not NULL itself). I found this ticket (https://trac.cakephp.org/ticket/6024) in the trac which is basically exactly what's happening to me as well. It appears this hasn't been fixed in the latest nightly though, and I was wondering if anyone had an idea on how to apply a fix until the bug has been resolved. I also found an older reported bug that appears to be the same thing (https:// trac.cakephp.org/ticket/5381). I've been digging in libs/model/datasources/dbo/dbo_mssql.php, and libs/model/db_acl.php, but haven't been able to see where the quotes are being applied to the NULL value. My guess is there just needs to be an extra conditional to check for a null value and not apply quotes in that case. If anyone knows where this can be resolved, that would be awesome. --~--~-~--~~~---~--~~ 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: Using a model without a table
I've been using the release candidates, and just upgraded to stable 1.2, hoping that would fix the issue but it hasn't. I've tried using MySQL now instead of MS SQL Server just to see if that had an effect (final will have to be MS though) but I'm still getting the same problem. If you're getting the correct functionality doing exactly the same thing, then I guess for some reason my model files aren't getting loaded at all. Not using a hacked core or anything, just everything straight from the repository. Weird. I guess the search continues. Any other ideas would be appreciated if someone stumbles upon this thread. On Dec 25, 10:14 pm, Dr. Loboto drlob...@gmail.com wrote: George, what Cake version do you use? I tried your posts test with table replacing (to users one in my case) and it was fine. Debug outputed Post::$useTable = users etc. Test with $useTable = false also was fine. Do you use hacked core or some automagic components/AppModel/ AppController or any other part of you code can take effect? BTW, Cake 1.2 finally released. No more beta on production! On Dec 23, 11:39 pm, George geo...@hakumei.net wrote: Thanks for the suggestion Dr. Loboto. That doesn't seem to do it for me either though. I'm still getting the stupid complaint that the table doesn't exist. If I add a reports table to the database, then it works fine, but obviously I don't want to have to add tables to the database I have no intention of using just to satisfy cake's need for finding one. Frustrating. If you have a moment, would you mind running a Debugger:dump($this-Utility); in your controller and letting me know what prints? As you can see from my post, I'm getting information that looks as if my Model isn't being loaded at all, and cake is defaulting to automagic functionality. If yours outputs AppModel::$useTable = false or Utility::$useTable = false, then obviously something is wrong with my configuration or setup, and not the actual model. Thanks for your help. On Dec 23, 10:46 am, Dr. Loboto drlob...@gmail.com wrote: Checked my models without tables, all of them work fine and differ from yours only in one param. All of them have $name : ?php class Utility extends AppModel { public $name = Utility; public $useTable = false;} ? Try add $name, maybe it is just strange bug? (and clear cache too) On Dec 23, 1:26 am, George geo...@hakumei.net wrote: Thanks for the suggestion, but unfortunately it didn't seem to do anything, and I still am getting a complaint that the reports table for the Report model was not found. Here is the exact code in the model: ?php class Report extends AppModel { var $useTable = false; public function getYearlySalesStats($year) { return $this-query(EXECUTE report_SalesStats $year, NULL); }} ? Annoying. The manual seems to say pretty cut and dry that by setting the $useTable member equal to false, cake will ignore the table requirement. For more info, I'm running cake on fedora/apache, and using MSSQL Server as my database. On Dec 19, 12:59 am, Kappa andrea.cappalu...@gmail.com wrote: Have you tried to reset the cache? Sometimes i have the same problem, and i solve it deleting the cache in /app/tmp/cache bye, Andrea On Dec 18, 6:55 pm,Georgegeo...@hakumei.net wrote: Hello. I'm pretty new to cake and am working on creating a reporting intranet application. Basically I aggregate a bunch of data through views and stored procedures on the database, and would like to build a Report model that will just have a bunch of custom functions to run the various stored procedures. As the functions would be returning datasets in different forms (based on the various reports), I wouldn't want this to actually be associated with any one table (the data is aggregated from many tables). I've read here that you can set the $useTable attribute in a model to false and then cake won't try to locate the model in the database. After setting $useTable to both false and null, I still have cake complaining that it can't find the table reports in the database when I call any action on the ReportsController. Is there something else I need to set/do? Or should I not be even using a model at all in this case, and query directly from the controller? To me, it seemed like encapsulating all database calls in models would be the best solution, but does anyone else with more cake experience have an opinion? 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
Re: Using a model without a table
Ok, I finally solved the problem, and I feel like an idiot. I had my model files named plural instead of singular, so that's why there weren't getting loaded. ie: app/models/posts.php instead of app/models/ post.php. Argh. I thought I checked that first but probably got caught up in other stuff and missed it. Thanks for all your help though. If someone else has a similar error, first thing is CHECK THE FILENAMES (and also class names for that matter, though that wasn't my problem). Exciting, now I can finally start doing some cool stuff with this framework. I guess the good news is I know my way around the file structure pretty good now. On Dec 29, 8:58 am, George geo...@hakumei.net wrote: I've been using the release candidates, and just upgraded to stable 1.2, hoping that would fix the issue but it hasn't. I've tried using MySQL now instead of MS SQL Server just to see if that had an effect (final will have to be MS though) but I'm still getting the same problem. If you're getting the correct functionality doing exactly the same thing, then I guess for some reason my model files aren't getting loaded at all. Not using a hacked core or anything, just everything straight from the repository. Weird. I guess the search continues. Any other ideas would be appreciated if someone stumbles upon this thread. On Dec 25, 10:14 pm, Dr. Loboto drlob...@gmail.com wrote: George, what Cake version do you use? I tried your posts test with table replacing (to users one in my case) and it was fine. Debug outputed Post::$useTable = users etc. Test with $useTable = false also was fine. Do you use hacked core or some automagic components/AppModel/ AppController or any other part of you code can take effect? BTW, Cake 1.2 finally released. No more beta on production! On Dec 23, 11:39 pm, George geo...@hakumei.net wrote: Thanks for the suggestion Dr. Loboto. That doesn't seem to do it for me either though. I'm still getting the stupid complaint that the table doesn't exist. If I add a reports table to the database, then it works fine, but obviously I don't want to have to add tables to the database I have no intention of using just to satisfy cake's need for finding one. Frustrating. If you have a moment, would you mind running a Debugger:dump($this-Utility); in your controller and letting me know what prints? As you can see from my post, I'm getting information that looks as if my Model isn't being loaded at all, and cake is defaulting to automagic functionality. If yours outputs AppModel::$useTable = false or Utility::$useTable = false, then obviously something is wrong with my configuration or setup, and not the actual model. Thanks for your help. On Dec 23, 10:46 am, Dr. Loboto drlob...@gmail.com wrote: Checked my models without tables, all of them work fine and differ from yours only in one param. All of them have $name : ?php class Utility extends AppModel { public $name = Utility; public $useTable = false;} ? Try add $name, maybe it is just strange bug? (and clear cache too) On Dec 23, 1:26 am, George geo...@hakumei.net wrote: Thanks for the suggestion, but unfortunately it didn't seem to do anything, and I still am getting a complaint that the reports table for the Report model was not found. Here is the exact code in the model: ?php class Report extends AppModel { var $useTable = false; public function getYearlySalesStats($year) { return $this-query(EXECUTE report_SalesStats $year, NULL); }} ? Annoying. The manual seems to say pretty cut and dry that by setting the $useTable member equal to false, cake will ignore the table requirement. For more info, I'm running cake on fedora/apache, and using MSSQL Server as my database. On Dec 19, 12:59 am, Kappa andrea.cappalu...@gmail.com wrote: Have you tried to reset the cache? Sometimes i have the same problem, and i solve it deleting the cache in /app/tmp/cache bye, Andrea On Dec 18, 6:55 pm,Georgegeo...@hakumei.net wrote: Hello. I'm pretty new to cake and am working on creating a reporting intranet application. Basically I aggregate a bunch of data through views and stored procedures on the database, and would like to build a Report model that will just have a bunch of custom functions to run the various stored procedures. As the functions would be returning datasets in different forms (based on the various reports), I wouldn't want this to actually be associated with any one table (the data is aggregated from many tables). I've read here that you can set the $useTable attribute in a model to false and then cake won't try to locate the model
Re: Using a model without a table
Hmm...are you sure you linked the right podcast? That seemed to be only about formHelper. I listened to the whole thing and didn't hear anything related to setting up models without tables. Does anyone know how to check some sort of diagnostics on a model at runtime to see if the parameters are even being loaded correctly? I tried for instance, making a simple controller/model combination and then using Debugger:dump(); However, the output doesn't seem to show that the table name was changed at runtime. Here's the code for the controller, model, and the output of the dump: ?php class PostsController extends AppController { function index() { $this-set('posts', 'test'); Debugger::dump($this-Post); } } ? ?php class Post extends AppModel { var $useTable = 'reports'; } ? OUTPUT: AppModel AppModel::$useDbConfig = default AppModel::$useTable = posts AppModel::$displayField = title AppModel::$id = false AppModel::$data = array AppModel::$table = posts AppModel::$primaryKey = id AppModel::$_schema = array AppModel::$validate = array AppModel::$validationErrors = array AppModel::$tablePrefix = AppModel::$name = Post AppModel::$alias = Post AppModel::$tableToModel = array AppModel::$logTransactions = false AppModel::$transactional = false AppModel::$cacheQueries = false AppModel::$belongsTo = array AppModel::$hasOne = array AppModel::$hasMany = array AppModel::$hasAndBelongsToMany = array AppModel::$actsAs = NULL AppModel::$Behaviors = BehaviorCollection object AppModel::$whitelist = array AppModel::$cacheSources = true AppModel::$findQueryType = NULL AppModel::$recursive = 1 AppModel::$order = NULL AppModel::$__exists = NULL AppModel::$__associationKeys = array AppModel::$__associations = array AppModel::$__backAssociation = array AppModel::$__insertID = NULL AppModel::$__numRows = NULL AppModel::$__affectedRows = NULL AppModel::$_findMethods = array AppModel::$_log = NULL To me, it seems like my model isn't even being loaded at all. The dump just seems to show the AppModel parameters, and not anything of my actual extended model Post. (note that $useTable is 'posts' and not 'reports', as I clearly set it in the model code) I must be doing something wrong here. On Dec 22, 8:50 pm, Webweave webwe...@gmail.com wrote: This podcasthttp://live.cakephp.org/shows/view/4has some info on what you need to do for this. There's a method you have to implement (sorry I didn't write it down). On Dec 22, 11:26 am, George geo...@hakumei.net wrote: Thanks for the suggestion, but unfortunately it didn't seem to do anything, and I still am getting a complaint that the reports table for the Report model was not found. Here is the exact code in the model: ?php class Report extends AppModel { var $useTable = false; public function getYearlySalesStats($year) { return $this-query(EXECUTE report_SalesStats $year, NULL); }} ? Annoying. The manual seems to say pretty cut and dry that by setting the $useTable member equal to false, cake will ignore the table requirement. For more info, I'm running cake on fedora/apache, and using MSSQL Server as my database. On Dec 19, 12:59 am, Kappa andrea.cappalu...@gmail.com wrote: Have you tried to reset the cache? Sometimes i have the same problem, and i solve it deleting the cache in /app/tmp/cache bye, Andrea On Dec 18, 6:55 pm,Georgegeo...@hakumei.net wrote: Hello. I'm pretty new to cake and am working on creating a reporting intranet application. Basically I aggregate a bunch of data through views and stored procedures on the database, and would like to build a Report model that will just have a bunch of custom functions to run the various stored procedures. As the functions would be returning datasets in different forms (based on the various reports), I wouldn't want this to actually be associated with any one table (the data is aggregated from many tables). I've read here that you can set the $useTable attribute in a model to false and then cake won't try to locate the model in the database. After setting $useTable to both false and null, I still have cake complaining that it can't find the table reports in the database when I call any action on the ReportsController. Is there something else I need to set/do? Or should I not be even using a model at all in this case, and query directly from the controller? To me, it seemed like encapsulating all database calls in models would be the best solution, but does anyone else with more cake experience have an opinion? 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 cake-php+unsubscr
Re: Using a model without a table
Thanks for the suggestion Dr. Loboto. That doesn't seem to do it for me either though. I'm still getting the stupid complaint that the table doesn't exist. If I add a reports table to the database, then it works fine, but obviously I don't want to have to add tables to the database I have no intention of using just to satisfy cake's need for finding one. Frustrating. If you have a moment, would you mind running a Debugger:dump($this- Utility); in your controller and letting me know what prints? As you can see from my post, I'm getting information that looks as if my Model isn't being loaded at all, and cake is defaulting to automagic functionality. If yours outputs AppModel::$useTable = false or Utility::$useTable = false, then obviously something is wrong with my configuration or setup, and not the actual model. Thanks for your help. On Dec 23, 10:46 am, Dr. Loboto drlob...@gmail.com wrote: Checked my models without tables, all of them work fine and differ from yours only in one param. All of them have $name : ?php class Utility extends AppModel { public $name = Utility; public $useTable = false;} ? Try add $name, maybe it is just strange bug? (and clear cache too) On Dec 23, 1:26 am, George geo...@hakumei.net wrote: Thanks for the suggestion, but unfortunately it didn't seem to do anything, and I still am getting a complaint that the reports table for the Report model was not found. Here is the exact code in the model: ?php class Report extends AppModel { var $useTable = false; public function getYearlySalesStats($year) { return $this-query(EXECUTE report_SalesStats $year, NULL); }} ? Annoying. The manual seems to say pretty cut and dry that by setting the $useTable member equal to false, cake will ignore the table requirement. For more info, I'm running cake on fedora/apache, and using MSSQL Server as my database. On Dec 19, 12:59 am, Kappa andrea.cappalu...@gmail.com wrote: Have you tried to reset the cache? Sometimes i have the same problem, and i solve it deleting the cache in /app/tmp/cache bye, Andrea On Dec 18, 6:55 pm,Georgegeo...@hakumei.net wrote: Hello. I'm pretty new to cake and am working on creating a reporting intranet application. Basically I aggregate a bunch of data through views and stored procedures on the database, and would like to build a Report model that will just have a bunch of custom functions to run the various stored procedures. As the functions would be returning datasets in different forms (based on the various reports), I wouldn't want this to actually be associated with any one table (the data is aggregated from many tables). I've read here that you can set the $useTable attribute in a model to false and then cake won't try to locate the model in the database. After setting $useTable to both false and null, I still have cake complaining that it can't find the table reports in the database when I call any action on the ReportsController. Is there something else I need to set/do? Or should I not be even using a model at all in this case, and query directly from the controller? To me, it seemed like encapsulating all database calls in models would be the best solution, but does anyone else with more cake experience have an opinion? 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Using a model without a table
Thanks for the suggestion, but unfortunately it didn't seem to do anything, and I still am getting a complaint that the reports table for the Report model was not found. Here is the exact code in the model: ?php class Report extends AppModel { var $useTable = false; public function getYearlySalesStats($year) { return $this-query(EXECUTE report_SalesStats $year, NULL); } } ? Annoying. The manual seems to say pretty cut and dry that by setting the $useTable member equal to false, cake will ignore the table requirement. For more info, I'm running cake on fedora/apache, and using MSSQL Server as my database. On Dec 19, 12:59 am, Kappa andrea.cappalu...@gmail.com wrote: Have you tried to reset the cache? Sometimes i have the same problem, and i solve it deleting the cache in /app/tmp/cache bye, Andrea On Dec 18, 6:55 pm,Georgegeo...@hakumei.net wrote: Hello. I'm pretty new to cake and am working on creating a reporting intranet application. Basically I aggregate a bunch of data through views and stored procedures on the database, and would like to build a Report model that will just have a bunch of custom functions to run the various stored procedures. As the functions would be returning datasets in different forms (based on the various reports), I wouldn't want this to actually be associated with any one table (the data is aggregated from many tables). I've read here that you can set the $useTable attribute in a model to false and then cake won't try to locate the model in the database. After setting $useTable to both false and null, I still have cake complaining that it can't find the table reports in the database when I call any action on the ReportsController. Is there something else I need to set/do? Or should I not be even using a model at all in this case, and query directly from the controller? To me, it seemed like encapsulating all database calls in models would be the best solution, but does anyone else with more cake experience have an opinion? 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Using a model without a table
Hello. I'm pretty new to cake and am working on creating a reporting intranet application. Basically I aggregate a bunch of data through views and stored procedures on the database, and would like to build a Report model that will just have a bunch of custom functions to run the various stored procedures. As the functions would be returning datasets in different forms (based on the various reports), I wouldn't want this to actually be associated with any one table (the data is aggregated from many tables). I've read here that you can set the $useTable attribute in a model to false and then cake won't try to locate the model in the database. After setting $useTable to both false and null, I still have cake complaining that it can't find the table reports in the database when I call any action on the ReportsController. Is there something else I need to set/do? Or should I not be even using a model at all in this case, and query directly from the controller? To me, it seemed like encapsulating all database calls in models would be the best solution, but does anyone else with more cake experience have an opinion? 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
setFlash extended parameters
Hi I'm a new Cake user, cutting my teeth on 1.2. Forgive me if I'm being stupid here but I'm finding the documentation a little unclear on the use of SessionComponent::setFlash() in its extended form. i.e: SessionComponent::setFlash ($message, $layout = 'default', $params = array(),$key = 'flash') I'm attempting this in my controller: $this-Session-setFlash(__('An error occurred while uploading your image: ' . $error, true), default, array(extra = EXTRAINFO HERE), imageError); and expecting to be able to find $extra set in the view for use: if($session-check(Message.imageError)){ $session-flash(imageError); echo pextra info: . $extra . /p; } Instead it returns an undefined var. I've also attempted to dig around the flash array like so - $session- flash(imageError.extra), but with no success. $session-flash(imageError) works fine. Could any cake gurus give me a pointer as to where I'm going wrong? Thanks in advance.. Marc --~--~-~--~~~---~--~~ 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: Moving data from a controller to a view after doing some queries
snip Thank you sir, you are a saint! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Moving data from a controller to a view after doing some queries
Hello! It seems like my lack of knowledge of MVC is once again holding me back. I'm attempting to develop some code that searches for users in the database and shows ones who's first or last names match. So, I have a function in my controller: function findsomeone() { if ($this-data) { $searchstring = $this-data['Client']['searchstring']; $numwords = substr_count($searchstring, ); $fields = array(0 = 'id', 'first_name', 'last_name'); if($numwords 0) { $searcharray = explode( ,$searchstring); $results = array(); foreach($searcharray as $saelement) { $conditions = Client.first_name LIKE ' . $saelement . ' OR Client.last_name LIKE ' . $saelement . '; $results = array_merge_recursive($results, $this-Client- findAll($conditions, $fields)); } } else { $conditions = Client.first_name LIKE ' . $searchstring . ' OR Client.last_name LIKE ' . $searchstring . '; $results = $this-Client-findAll($conditions, $fields); } //flatten the array, and then pull out all the duplicate entries $flattened = array(); for($i = 0; $i count($results); $i++) { array_push($flattened, $results[$i]['Client']); } array_multisort($flattened, SORT_ASC); for($i=(count($flattened)-1); $i0; $i--) { if($flattened[$i-1]['id'] == $flattened[$i]['id']) { array_splice($flattened, $i-1, 1); } } // and here I'm stuck } } So, $flattened has the data I want, and I know that in the view, I should just be dropping code like echo $client['Client'] [first_name']; to display the first name, for example. What's not clear to me is how to pass that data back to the controller. Looking at the index function that bake created for me, I see the cryptic: function index() { $this-Client-recursive = 0; $this-set('clients', $this-paginate()); } and unfortunately, it's as clear as mud to me as to how that actually works, and I can't find a good discussion of what it's doing, so I can't figure out how to get my data from $flattened back to the view. Can anyone tell me where I can find a good discussion of how to get this to work? Thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: enum
On Jan 25, 8:32 am, MonkeyGirl [EMAIL PROTECTED] wrote: How would you get the enum values from the model or controller? By far the easiest way is to go tohttp://cakeforge.org/snippet/detail.php?type=snippetid=112 and copy and paste the code that's there into app_model.php, then you can just use lines like the following in your code: $types = $this-Album-getEnumValues('type'); In this example, 'type' is the name of the enum column, Album is the model it's in, and 'types' is the variable that will automatically be picked up by this line in the view (assuming you're using Cake 1.2 with its form helper): echo $form-input('type'); This will give you a dropdown, just like the one you get for foreign keys. Hope that helps, Zoe. Looks simple enough, but I'm very new to the whole Model-View- Controller paradigm, so I can't quite make sense of this. Adding the first part of that code into the app_model.php file is straightforward enough, and I only need the function add() section if I intend to use this functionality with Bake (right?) which I currently don't. So, would I want to say in some view: $types = $this-Album-getEnumValues('type'); echo $form-input('type'); $labels = $this-Album-getEnumValues('label') echo $form-input('label') Or that's what I'd think to do at first glance, but it doesn't seem to work - $this seems to point to the current view object and not the Album object, which I suppose makes sense. But then it's not clear to me where the $types = $this-Album-getEnumValues('type'); line ought to go, if not in the view page. Thanks in advance for any clarification you can send my way! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help configuring CakePHP 1.1 or 1.2 for a total CakePHP newbie
Hello! I'd like to get started using Cake, but so far I haven't had a lot of luck. I've been attempting to follow the excellent Cook up Web sites fast with CakePHP, Part 1 hosted at: http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html My first attempt involved using CakePHP 1.2, beta version 6311. After downloading it, unpacking it in a folder beneath my webroot, changing the permissions to 777 on /app/tmp and attempting to visit http://www.myurl.com/cake12/ (which should bring up the configuration/ welcome page) my browser hangs for a minute before spitting out: Fatal error: Maximum execution time of 60 seconds exceeded in /var/www/ html/cake12/cake/libs/view/view.php on line 634 Fatal error: Call to a member function on a non-object in /var/www/ html/cake12/cake/libs/cache.php on line 208 Undeterred, I switched to CakePHP 1.1.9.6305, upacked in a folder beneath my webroot called cake11, changed the permissions of the /app/ tmp folder, and tried to visit http://www.myurl.com/cake11/ - this time with some success, although I don't see any section about my cache being set up properly or my tmp directory being writable. Nonetheless I plowed ahead through the tutorial, and created the files listed on page 3 of the tutorial. So, when I visited http://www.myurl.com/cake11/users/register I saw the registration page and filled it out. When I hit the registration button, my URL is changed to http://www.myurl.com/users/register and I'm told that page doesn't exist, which makes sense. I tried changing the ROOT and APP_DIR values in /app/webroot/ index.php, but that only seemed to break everything, so I changed it back. My next attempt was to copy all of the files in /webroot/cake11 directly into /webroot. This works to some degree - I quickly defined a index() function in /app/controllers/users_controller this displays a small message using $this-flash, so when I retrieve http://www.myurl.com/users I see the message, but attempting to visit http://www.myurl.com/users/register gives me the same page doesn't exist message, even though I know that register.ctp is there. So, my questions are: 1) Can anyone make sense of the error I'm getting with 1.2? I'm happy to stick with 1.1, if need be, but I'd be glad to get it working. 2) What is the correct way to tell CakePHP to use a certain path? Leaving files in /webroot/cake11 works until it needs to (I'm guessing) build a URL, at which point it assumes the Cake files should be in the /webroot folder; and moving them to /webroot seems to make the register.ctp view seem to not exist at all as far as the web server is concerned. Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help configuring CakePHP 1.1 or 1.2 for a total CakePHP newbie
Hello! I'd like to get started using Cake, but so far I haven't had a lot of luck. I've been attempting to follow the excellent Cook up Web sites fast with CakePHP, Part 1 hosted at: http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html My first attempt involved using CakePHP 1.2, beta version 6311. After downloading it, unpacking it in a folder beneath my webroot, changing the permissions to 777 on /app/tmp and attempting to visit http://www.myurl.com/cake12/ (which should bring up the configuration/ welcome page) my browser hangs for a minute before spitting out: Fatal error: Maximum execution time of 60 seconds exceeded in /var/ www/ html/cake12/cake/libs/view/view.php on line 634 Fatal error: Call to a member function on a non-object in /var/www/ html/cake12/cake/libs/cache.php on line 208 Undeterred, I switched to CakePHP 1.1.9.6305, upacked in a folder beneath my webroot called cake11, changed the permissions of the /app/ tmp folder, and tried to visit http://www.myurl.com/cake11/ - this time with some success, although I don't see any section about my cache being set up properly or my tmp directory being writable. Nonetheless I plowed ahead through the tutorial, and created the files listed on page 3 of the tutorial. So, when I visited http://www.myurl.com/cake11/users/register I saw the registration page and filled it out. When I hit the registration button, my URL is changed to http://www.myurl.com/users/register and I'm told that page doesn't exist, which makes sense. I tried changing the ROOT and APP_DIR values in /app/webroot/ index.php, but that only seemed to break everything, so I changed it back. My next attempt was to copy all of the files in /webroot/cake11 directly into /webroot. This works to some degree - I quickly defined a index() function in /app/controllers/users_controller this displays a small message using $this-flash, so when I retrieve http://www.myurl.com/users I see the message, but attempting to visit http://www.myurl.com/users/register gives me the same page doesn't exist message, even though I know that register.ctp is there. So, my questions are: 1) Can anyone make sense of the error I'm getting with 1.2? I'm happy to stick with 1.1, if need be, but I'd be glad to get it working. 2) What is the correct way to tell CakePHP to use a certain path? Leaving files in /webroot/cake11 works until it needs to (I'm guessing) build a URL, at which point it assumes the Cake files should be in the /webroot folder; and moving them to /webroot seems to make the register.ctp view seem to not exist at all as far as the web server is concerned. Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Inflections not being applied?
Hey everyone, I have set up CakePHP 1.2 beta on my host and am writing a CMS. I have set up two models, one called Menus and the other called Contents. Menus - hasMany - Contents, while Contents - belongsTo - Menus. In my controller code, I am at the stage of validating my data against the two models. I have one page, mysite.com/admin/menus/add that allows the user to enter Menu information (eg. page title, stub, parent menu, etc) and another fieldset for the actual content (this is so that one menu can have different versions of content). In my controller code, I have as follows: $this-Menu-set($this-data); $this-Menu-validates(); $this-Menu-Content-set($this-data); $this-Menu-Content-validates(); ... which seems to make sense to me, models being first-char- capitalised and in singular form. This also follows for my user management module that I wrote, the model is always referenced as singular. However, when I execute this code, CakePHP is imperative that 'Content' should really be 'Contents'. Executing the above code gives me the following PHP error: Fatal error: Call to a member function on a non-object in /app/ controllers/menus_controller.php on line 130 Changing 'Content' to 'Contents' makes it all work. A part of me is feeling like I should just fix what's broke and who cares if it's theoretically wrong, but a larger part of me wants to make this work theoretically and practically as well (plus it's more poetic!). I have included a link to a paste of my inflections.php file, I tried to modify it so that I can force the singular of 'Contents' to be 'Content', but it doesn't seem to make any difference. http://bin.cakephp.org/view/905242165 Any ideas out there? TIA. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Inflections not being applied?
Hey everyone, I have set up CakePHP 1.2 beta on my host and am writing a CMS. I have set up two models, one called Menus and the other called Contents. Menus - hasMany - Contents, while Contents - belongsTo - Menus. In my controller code, I am at the stage of validating my data against the two models. I have one page, mysite.com/admin/menus/add that allows the user to enter Menu information (eg. page title, stub, parent menu, etc) and another fieldset for the actual content (this is so that one menu can have different versions of content). In my controller code, I have as follows: $this-Menu-set($this-data); $this-Menu-validates(); $this-Menu-Content-set($this-data); $this-Menu-Content-validates(); ... which seems to make sense to me, models being first-char- capitalised and in singular form. This also follows for my user management module that I wrote, the model is always referenced as singular. However, when I execute this code, CakePHP is imperative that 'Content' should really be 'Contents'. Executing the above code gives me the following PHP error: Fatal error: Call to a member function on a non-object in /app/ controllers/menus_controller.php on line 130 Changing 'Content' to 'Contents' makes it all work. A part of me is feeling like I should just fix what's broke and who cares if it's theoretically wrong, but a larger part of me wants to make this work theoretically and practically as well (plus it's more poetic!). I have included a link to a paste of my inflections.php file, I tried to modify it so that I can force the singular of 'Contents' to be 'Content', but it doesn't seem to make any difference. http://bin.cakephp.org/view/905242165 Any ideas out there? TIA. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Missing Action / Controller / View doesn't see JavascriptHelper?
Hey everyone, I think I have broken my CakePHP application that I am making... As you all very well know, CakePHP throws error messages when it comes across a missing action, controller, view, etc. However, I have done something to my default.thtml file and now this does not function. If I was to go to a URL within my project, eg. www.example.com/fdjgddf instead of www.example.com/login (fdjgddf isn't an action or a controller), I am faced with the following: Fatal error: Call to a member function on a non-object in /app/views/ layouts/default.thtml on line 5 Line 5 in my default.thtml file is: ?php echo $javascript-link('prototype'); ? It seems that it's not loading up the JavascriptHelper for some reason. It seems to load HtmlHelper fine. Mind you, when an actual controller / action has been referenced (eg. www.example.com/login), everything loads fine, including JavascriptHelper -- this only happens when there's a missing controller / action / view. Is there a way to fix this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Missing Action / Controller / View doesn't see JavascriptHelper?
Actually, sorry I had found out how to do it! I just added the line: var $helpers = array(Html, Form, Javascript, Ajax); to my app_controller.php file and it's working fine. Sorry for wasting resources! On Oct 16, 2:25 pm, George @ Dogma [EMAIL PROTECTED] wrote: Hey everyone, I think I have broken my CakePHP application that I am making... As you all very well know, CakePHP throws error messages when it comes across a missing action, controller, view, etc. However, I have done something to my default.thtml file and now this does not function. If I was to go to a URL within my project, eg.www.example.com/fdjgddf instead ofwww.example.com/login(fdjgddf isn't an action or a controller), I am faced with the following: Fatal error: Call to a member function on a non-object in /app/views/ layouts/default.thtml on line 5 Line 5 in my default.thtml file is: ?php echo $javascript-link('prototype'); ? It seems that it's not loading up the JavascriptHelper for some reason. It seems to load HtmlHelper fine. Mind you, when an actual controller / action has been referenced (eg.www.example.com/login), everything loads fine, including JavascriptHelper -- this only happens when there's a missing controller / action / view. Is there a way to fix this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---