Re: strange html code behavior (ajax, firefox)
ah yes... i forgot to check adjustperm view... but... ids generated in both views are the same (controller_action_roleid), strange thing is that only two actions are not visible add and adjustperm i added in meantime two controllers with standard crud actions and both of them have action add invisible (!). ad errors in log... it was an $this-log() inside adjustperm.ctp :P ok... same ids in acl.ctp and adjustparm.ctp: controller_action_roleid - dont update controlleraction_roleid - that works controller_actionroleid - dont update controller__action_roleid - dont update whats with _ ? :P now i changed ids everywhere to controlleraction_roleid and... no problems under Firefox/IE wierd ;) --~--~-~--~~~---~--~~ 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: Are routes this flexible?
Sorry for the late comeback... I didn't want to break all the old links, so I left the parsing algorithm as it is. I was able to reduce the lines of code thanks to some more efficient features in 1.2 anyway, so that's alright. :o) There's one thing I wonder about though. The URLs used in the app can be either: /:controller/:action/:id for things like /events/edit/id, or they're: /:controller/:random/:params for things like /events/in/area/concerts. The latter ones are all routed through to $EventsController-index(), where the URL parsing magique happens. Right now I'm doing this by specifying these routes: Router::connect('/events/add', array('controller' = 'events', 'action' = 'add')); Router::connect('/events/edit/*', array('controller' = 'events', 'action' = 'edit')); Router::connect('/events/show/*', array('controller' = 'events', 'action' = 'show')); Router::connect('/events/*', array('controller' = 'events', 'action' = 'index')); Is there a way to consolidate these rules somehow? Basically, everything that is not an actual action in my EventsController should be send to the index() method. Will I have to override the error handling class to do that? Chrs, Dav On 11 Aug 2008, at 22:09, [EMAIL PROTECTED] wrote: Hi David, I am no authority but from what I know of the router in Cake I'd say probably not. You may be able to get part of the way there with named routes: / events/in:newyork/near:MickyDs Problem is you seem to be limited to one of each. You can not have Router parse two named parameters with the same name and get an array. Instead a later parameter overwrites the previous. near:thefirst/ near:thesecond generates only a param for near = thesecond It would be cool if it worked the other way and maybe you can tweak the code to do it for you. But you would still not have exactly the urls you want. What could possibly do it all for you is regexp routing. I just remember reading about it a while back but since I suck at regexp I took little notice. If that feature can overcome the limitation above then you could probably write a routing rule-set for your app. It is the last thing tested in router.test.php /Martin On Aug 11, 11:10 am, David Christopher Zentgraf [EMAIL PROTECTED] wrote: Hi, I'm in the midst of updating a 1.1 app to Cake 1.2, and am looking into how flexible routes are. The app centers around really custom URLs, like: /events/in/place/2008/08/13 or /events/concerts/near/station/ 2009/04 There can be four different parameters in the URL: - areas, distinguished by keyword /in/ - stations or POIs, distinguished by keyword /near/ - categories, distinguished by not being a number - dates, distinguished by being a number These can occur in any order and quantity. While I'm updating anyway, I'd like to replace the parsing algorithm for the URL by routes if at all possible; but routes don't seem to be flexible enough for the task, as they require parameters in a fixed order? Any input appreciated, Dav --~--~-~--~~~---~--~~ 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: File upload
I've written this behavior which I typically use for file uploads. It's short and pretty easy to use, maybe you'll find it useful. You can set the directory in which the file should be saved by setting the option destination. If you attact the behavior like this, $this-YourController-Behaviors-attach('File', array('destination' = 'yourpath')); you can construct the path from variables available to your controller. On 19 Aug., 22:18, bartez [EMAIL PROTECTED] wrote: Hey all, I've scouted both here and the bakery etc and have had no success in finding the answer to my problem. I would like to upload an image and save it in a file system (not a database). I would like the structure to be as follows img / items / groups /id /each individual image here I've done this before in normal php but I'm sure there must be a cake way!! Thanks for your help in advance. Alex --~--~-~--~~~---~--~~ 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: File upload
Bob, Dan, Thanks very much that's great!! I'll work through them both now. Really appreciate it. Alex On 20 Aug, 08:06, Dan Soendergaard [EMAIL PROTECTED] wrote: I've written this behavior which I typically use for file uploads. It's short and pretty easy to use, maybe you'll find it useful. You can set the directory in which the file should be saved by setting the option destination. If you attact the behavior like this, $this-YourController-Behaviors-attach('File', array('destination' = 'yourpath')); you can construct the path from variables available to your controller. On 19 Aug., 22:18, bartez [EMAIL PROTECTED] wrote: Hey all, I've scouted both here and the bakery etc and have had no success in finding the answer to my problem. I would like to upload an image and save it in a file system (not a database). I would like the structure to be as follows img / items / groups /id /each individual image here I've done this before in normal php but I'm sure there must be a cake way!! Thanks for your help in advance. Alex --~--~-~--~~~---~--~~ 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: find list vs find all - Manipulating the format of a javascript object
Try it like this: $params = array( // ... 'fields' = array('State.id', 'State.name', 'State.id') // ... ); $result = array_values($this-State-find('list', $params)); On Aug 19, 6:32 pm, Josoroma [EMAIL PROTECTED] wrote: With the following piece of code: function getJsonStates() { //Configure::write(debug,0); $params = array( 'conditions' = null, 'fields' = array( 'State.id', 'State.name' ), 'recursive' = 0 ); $states = $this-State-find('all', $params); $this-set(compact('states')); } Im generating a javascript object like this: [{State:{id:1,name:Lizenburgue}},{State: {id:2,name:Oak}},{State:{id:3,name:San Pedro}}] Using list instead of all: $this-State-find('list', $params); Im generating a javascript object like this: [{1:Lizenburgue,2:Oak,3:San Pedro}] ***But i need to generate the result as: [{1:Lizenburgue},{2:Oak},{3:San Pedro}] There exist some way of doing that using find with extract or combine? Any help is welcome, Thanks in advance. --~--~-~--~~~---~--~~ 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: Newbie of Cake Php : Problems with Vista Installation and First Application
Hi 1. The log line you get shows clearly that it's an Apache issue. The message obviously says that you must enable FollowSymLinks in your httpd.conf so that mod_rewrite works (see here : https://trac.cakephp.org/ticket/1700)... you must put Options FollowSymLinks in your httpd.conf (there may be already an Options line, in your Directory section - the one that refers to you www root, to which you can add FollowSymLinks). See more Apache specific documentation for this issue (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) 2. I don't know what Uniform Server is, but from your directory structure, it doesn't seem like you actually use user directories; you just use a regular subdirectory of your document root (www). user directories is an Apache module that basically redirects http://your_server/~your_user_name/; to a subdirectory of your personal home directory (in Windows, it may be C:\Documents and Settings\your_user_name\htdocs or C:\.\public_html). So I think you don't need the RewriteRule extra line. Try this, and it *may* work. +++ Clément On Tue, Aug 19, 2008 at 9:57 PM, www.landed.at [EMAIL PROTECTED] wrote: I have followed all except the last line of that link which is # If you are installing CakePHP into a user directory (http:// example.com/~username), you'll need to modify the .htaccess file in the base directory of your CakePHP installation. Just add the line RewriteBase /~myusername/ in uniform server the structure is C:\Uniform Server\udrive\www\fb00\ [here i have app, cake,vendors etc and the htaccess file ] so eith that structure localhost points to the www root folder where I have multiple sites. So i added as per the instruction above and get the htaccess file in the application root to be IfModule mod_rewrite.c RewriteEngine on RewriteRule^$ app/webroot/[L] RewriteRule(.*) app/webroot/$1 [L] RewriteBase /~fb00/ /IfModule so is that right, I dont know what else is wrong, I have mod rewrite working for other things ok. here is my server log error [error] [client 127.0.0.1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: W:/www/fb00/, referer: http://localhost/ thanks for any help this is my second night of frustration with nothing working. --~--~-~--~~~---~--~~ 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: Newbie of Cake Php : Problems with Vista Installation and First Application
On Wed, Aug 20, 2008 at 10:07 AM, clemos [EMAIL PROTECTED] wrote: Hi 1. The log line you get shows clearly that it's an Apache issue. The message obviously says that you must enable FollowSymLinks in your httpd.conf so that mod_rewrite works (see here : https://trac.cakephp.org/ticket/1700)... you must put Options FollowSymLinks in your httpd.conf (there may be already an Options line, in your Directory section - the one that refers to you www root, to which you can add FollowSymLinks). See more Apache specific documentation for this issue (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) 2. I don't know what Uniform Server is, but from your directory structure, it doesn't seem like you actually use user directories; you just use a regular subdirectory of your document root (www). user directories is an Apache module that basically redirects http://your_server/~your_user_name/; to a subdirectory of your personal home directory (in Windows, it may be C:\Documents and Settings\your_user_name\htdocs or C:\.\public_html). So I think you don't need the RewriteRule extra line. I meant : you don't need the RewriteBase extra line. The default Cake .htaccess file should work. Try this, and it *may* work. +++ Clément On Tue, Aug 19, 2008 at 9:57 PM, www.landed.at [EMAIL PROTECTED] wrote: I have followed all except the last line of that link which is # If you are installing CakePHP into a user directory (http:// example.com/~username), you'll need to modify the .htaccess file in the base directory of your CakePHP installation. Just add the line RewriteBase /~myusername/ in uniform server the structure is C:\Uniform Server\udrive\www\fb00\ [here i have app, cake,vendors etc and the htaccess file ] so eith that structure localhost points to the www root folder where I have multiple sites. So i added as per the instruction above and get the htaccess file in the application root to be IfModule mod_rewrite.c RewriteEngine on RewriteRule^$ app/webroot/[L] RewriteRule(.*) app/webroot/$1 [L] RewriteBase /~fb00/ /IfModule so is that right, I dont know what else is wrong, I have mod rewrite working for other things ok. here is my server log error [error] [client 127.0.0.1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: W:/www/fb00/, referer: http://localhost/ thanks for any help this is my second night of frustration with nothing working. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
requestAction redirects me. (probably something stupid, I just can't see it)
This has been driving me nuts for a few hours now and I cant figure out what I am doing wrong. I am on Cake 1.2rc2 I am doing a $this-requestAction('controller/action/idnum') but I get redirected to that action instead of getting any return values. I have done it before without problems (or so I believe) but now I cant seem to get it right. I have tried adding the option return without any change in behaviour. I have added $this-Auth-allow() to prevent any authentication related problem. // echo 'hello'; // this would result in a headers already sent error $ret = $this-requestAction('controller/action/idnum'); // this redirects debug($ret); // this line never even runs. I am trying to notify that other controller of an event (no rendering as such) and this is the only way I know of calling actions on other controllers. Any idea what I am missing here? I feel like I have a temporary blindspot for the root of this problem :) /Martin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Blogger mirror of the cakephp list: potentially dangerous, surely stupid
Hi all Does someone know what is this : http://cake--php.blogspot.com/ I suggest that we try to stop that, because our emails are exposed to spam harvesters, and because it's totally nonsense. Googlegroups are fine, Nabble is fine (though I find it already quite parasite...), but this blogger mirror is the stupidest thing I've ever seen... Maybe searching for @blogspot.com (or blogspot mail update like email adresses) in the group member list ? +++ Clément --~--~-~--~~~---~--~~ 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: Blogger mirror of the cakephp list: potentially dangerous, surely stupid
http://cake--php.blogspot.com/2008/08/blogger-mirror-of-cakephp-list.html hehe On Wed, Aug 20, 2008 at 12:19 PM, clemos [EMAIL PROTECTED] wrote: Hi all Does someone know what is this : http://cake--php.blogspot.com/ I suggest that we try to stop that, because our emails are exposed to spam harvesters, and because it's totally nonsense. Googlegroups are fine, Nabble is fine (though I find it already quite parasite...), but this blogger mirror is the stupidest thing I've ever seen... Maybe searching for @blogspot.com (or blogspot mail update like email adresses) in the group member list ? +++ Clément --~--~-~--~~~---~--~~ 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: OrderedBehavior - Order your lists in a TreeBehavior like manner, but only for one level.
@Tarique I am not arguing the value of bakery - you missed the point :D Well, in all fairness, I imagine Alkemann already knows about search engines but he would still like to publish his work on the Bakery. I believe that is the main point here. I propose we should think of how we can use the Bakery to become our ultimate resource for articles. I have a couple of simple ideas and if anyone is also interested, I'll start a thread about this topic so we can give positive feedback, ideas and encouragement to the Bakery developers which they can bear in mind if they plan any future improvements. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Some questions about ACL implementation
Hopefully these aren't lame questions. Believe me, I've spent lots of time reading every tutorial I can find and lots of threads on this group. I still have a few questions though. 1. Many of the implementations of user groups in ACL have a UserGroup model (User belongsTo UserGroup), which is then followed through in the AROs table. Isn't this just duplication? Should I not just save userGroups into the AROs table and be done with it? You can still edit group names by directly manipulating the record in ARO, no? Granted that you can't add extra fields, such as description, but if I'm simply storing a group name AND using aros_acos to test the group's permissions, shouldn't this suffice? 2. Is there any reason that the ARO tree isn't stored in the Auth Session on login, to save having to call it on every page view? 3. Am I right in thinking that CRUD-based authorisation doesn't allow you to restrict the whole admin site (i.e. admin_index, admin_view etc) to an administrators group? For this actions-based authorisation is what you need? 4. When using plugins the $this-params['controller] variable isn't set if you use the default controller, e.g. the 'posts' controller in the 'posts' plugin, with the route /posts/view. This causes Auth- isAuthorized() to break. Is this the best way to fix this problem this (in AppController beforeFilter function), or is there a better way?: if(!$this-Auth-params['controller']) { $this-Auth- params['controller'] = $this-params['plugin']; } Thanks for any help! --~--~-~--~~~---~--~~ 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 woes (cake_1.2.0.7296-rc2)
var $hasMany = 'Bid'; I could be wrong here, but I *think* that this has to be an array, even if there's only one item in it. As in: var $hasMany = array( 'Bid' = array( 'className' = 'Bid' ) ); Does updating that help at all? Zoe. --~--~-~--~~~---~--~~ 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 Workshop in Raleigh, NC (Sep 6-7)
Hey folks, if you haven't heard about the CakePHP workshop in Raleigh yet, here is your chance to grab one of the last seats. In 2 days Garrett Woodworth, Nate Abele, Felix Geisendörfer and Tim Koschützki will teach you everything you need to know to bake great CakePHP applications. On top of the normal presentations we have a second room were the speakers that are not presenting at the time will do individual consulting, ad-hoc talks and share things they are currently working on. We got Marc Grabanski from the jQuery UI team to come. He'll hang out in room 2 and can be bothered with any jQuery / JS question you might have : ). For all the information, visit the announcement page. http://debuggable.com/posts/cakephp-workshop-in-raleigh-nc-sep-6-to-7:488a234d-39fc-4d06-9c57-65aa4834cda3 -- Felix Geisendörfer aka the_undefined --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Filter a paginated dataset using a related field through a habtm relationship (1.2)
Does this mean that 1.2 still can't filter a result set by a related model over habtm? I've been trying to filter my Links by Category to no avail today. Link habtm Category Category habtm Link $this-set('links', $this-paginate('Link', array('Category.id'=$this- data['Link']['category_id']))); Which fails because CakePHP won't join the related model in the query. Will I be reduced to creating a Model for the join CategoriesLink and then writing my own query to grab data from it? It seems determined to do two separate queries. The only other way I could think of, which I haven't tried yet, was to use /category/5/$link_id which might work, but I assumed would suffer the same fate in the sql of missing a join. Or should I be making an on-the-fly bind using a belongsTo association to force the join, which would then pickup my conditions? I have read the CakeBaker article (http://cakebaker.42dh.com/ 2007/10/17/pagination-of-data-from-a-habtm-relationship/), but that looks to be for 1.1 as my existing habtm works for reading and saving, but not for when you want to adjust the resultset using a field from the related model. Idea's or links would be appreciated! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Model-find() using group parameter
Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. --~--~-~--~~~---~--~~ 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: Model-find() using group parameter
2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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: Model-find() using group parameter
2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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: Model-find() using group parameter
Oh, I just got here to reply my own question, and there are two answers already. Thanks for the answer! On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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: Model-find() using group parameter
What about using 'list' instead of 'all', it is failing: $this-Production-find('list', array('fields' = 'DISTINCT supplier')); CakePHP is trying to fetch Product.id as well. Is this a feature or a bug? :) On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ 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 woes (cake_1.2.0.7296-rc2)
Hi eleven10, This table has P (bid_session_id, user_id). If I remove that and add an id field as PK, things start working. However, since I am not interested in using this join model directly, I shouldn't have to do this ... as far as I understand from the manual and other cake blogs/tutorials. Nope, your can not use composite keys with cakephp, you have to have an ID (or a field that you use as the primary, auto-incrementing id) - search the group for more background on this. (b) The generated scaffold view for /bid_sessions/add correctly shows me a list (multi-select) of users to choose from for that session. However, in /users/add, the code shows a select drop down for Bid Session Registrations (and options for listing/creating Bid Session Registrations). Shouldn't cake be generating a list of Bid Sessions to choose from (as in the other case)? make sure you define your associations in alphabetical order, scaffolding can be quite picky about that (least it was last time I used it, though that was some time ago!). hope this helps, jon -- 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: HABTM cascading delete
I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when i delete table record 1 i want to delete the relationship with table and the table 2 record as well but when i delete from table 2 i want to keep table 1 record is there any feature in cakephp for cascading in habtm? --~--~-~--~~~---~--~~ 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 cascading delete
Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need to delete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when i delete table record 1 i want to delete the relationship with table and the table 2 record as well but when i delete from table 2 i want to keep table 1 record is there any feature in cakephp for cascading in habtm? --~--~-~--~~~---~--~~ 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: requestAction redirects me. (probably something stupid, I just can't see it)
Update: The problem I was having seem to have something to do with Auth after all. I have not figured out how or why but trashing some session data and starting over again fixed it for me. Now requestAction actually requests instead of redirecting. Strange. I have not been able to replicate the problem. /Martin On Aug 20, 12:15 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: This has been driving me nuts for a few hours now and I cant figure out what I am doing wrong. I am on Cake 1.2rc2 I am doing a $this-requestAction('controller/action/idnum') but I get redirected to that action instead of getting any return values. I have done it before without problems (or so I believe) but now I cant seem to get it right. I have tried adding the option return without any change in behaviour. I have added $this-Auth-allow() to prevent any authentication related problem. // echo 'hello'; // this would result in a headers already sent error $ret = $this-requestAction('controller/action/idnum'); // this redirects debug($ret); // this line never even runs. I am trying to notify that other controller of an event (no rendering as such) and this is the only way I know of calling actions on other controllers. Any idea what I am missing here? I feel like I have a temporary blindspot for the root of this problem :) /Martin --~--~-~--~~~---~--~~ 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 cascading delete
the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need to delete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when i delete table record 1 i want to delete the relationship with table and the table 2 record as well but when i delete from table 2 i want to keep table 1 record is there any feature in cakephp for cascading in habtm? --~--~-~--~~~---~--~~ 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: Model-find() using group parameter
It's a feature, find('list') is usually done to build options for a select box. On Aug 20, 8:39 am, bitkidoku [EMAIL PROTECTED] wrote: What about using 'list' instead of 'all', it is failing: $this-Production-find('list', array('fields' = 'DISTINCT supplier')); CakePHP is trying to fetch Product.id as well. Is this a feature or a bug? :) On Aug 20, 3:12 pm, Amit Badkas [EMAIL PROTECTED] wrote: 2008/8/20 Amit Badkas [EMAIL PROTECTED] 2008/8/20 bitkidoku [EMAIL PROTECTED] Hello everyone, I am using CakePHP to build an application that will run on en existing database. The problem I am facing is simple, I have products table and let's say it is like this: id, name, supplier Some stupid programmer (yes I am angry to him) didn't created the table with supplier_id. So every time a product is being added supplier field must be entered manually. This is not my problem. What I want to do is to retrieve all the unique supplier names. - To get unique suppliers, run query, SELECT DISTINCT supplier FROM products - Or using cake, $this-Production-find('all', array('fields' = 'DISTINCT supplier')); I tried: $this-Product-find( 'all', array( 'fields' = array('Product.supplier'), 'group' = 'Product.supplier' ) ); It does not work. When I query the database manually using SELECT supplier FROM table GROUP BY supplier it works. Thank you very much for your answers. -- Amit http://amitrb.wordpress.com/http://coppermine-gallery.net/http://chee... --~--~-~--~~~---~--~~ 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: textbook find() query just doesn't work
The example in the manual is a little misleading. It assumes a belongsTo relationship between Post and Author (i.e. Post belongsTo Author). In that case a JOIN will be performed (remember, JOINs are only done for hasOne and belongsTo). I think the confusion is that it also mentions a hasMany relationship (i.e. Author hasMany Post), but in that case the JOIN is not forced. So, in other words, if you assumed that in the manual example there would be a call: $this-Post-find(... then a JOIN is performed and everything works as expected. If, however, it was $this-Author- find(... then one would likely to see an error similar to yours. P.S. I've submitted a correction to the manual. On Aug 19, 8:16 pm, Christian [EMAIL PROTECTED] wrote: In the manual I found an example of what I'm trying to do, except it doesn't work... - Let's say you had a hasMany/belongsTo relationship between Posts and Authors, which would result in a LEFT JOIN. Let's say you wanted to find all the posts that contained a certain keyword (“magic”) or were created in the past two weeks, but you want to restrict your search to posts written by Bob: code: array ( Author.name = Bob, or = array ( Post.title LIKE = %magic%, Post.created = date('Y-m-d', strtotime(-2 weeks)) ) ) - So you pass that as conditions to your find() call. I have a Game model and a GamePlayer model. Game hasMany GamePlayer. GamePlayer belongsTo Game. I want to find all games with inherent Game.status=1, and with an associated GamePlayer.user_id=1 $cond = array(conditions=array(Game.status=1)); $games = $this-Game-find('all',$cond)); -- This will return all the games with status=1, and right underneath the associated GamePlayers however, when i say.. $cond = array(conditions=array(Game.status=1,GamePlayer.user_id=1)); and repeat the find... it spits back at me Unknown column 'Game.status' in 'where clause' because it doesn't do a JOIN like the example from the cookbook says. I know this topic has come up on the google group elsewhere, but they either don't address this exact issue, or i try what is suggested and still no luck. I'd like to think this is a pretty basic and overused query for almost any application of databases. thanks, Christian --~--~-~--~~~---~--~~ 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 woes (cake_1.2.0.7296-rc2)
Nope, your can not use composite keys with cakephp, you have to have an ID (or a field that you use as the primary, auto-incrementing id) - search the group for more background on this. Correct me if I'm wrong here, but I thought joiner tables for HABTM relationships were the exception to this rule, and always consisted of two columns of foreign keys, that had to act as one big primary key. Ah: http://book.cakephp.org/view/24/model-and-database-conventions You're right. Now I'll have to work out where I misread about joiner tables... Zoe. --~--~-~--~~~---~--~~ 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 multiple inserts
What code specifically did you look at? On Aug 8, 9:23 am, lightglitch [EMAIL PROTECTED] wrote: Solved it by looking to model test cases code. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Fixture fails to create table
Hi I started to write tests, but fails at the begining. I created model, fixture and sample test case: http://bin.cakephp.org/view/1606012040 But when I trigger such test I get only such error: Fatal error: Call to a member function trigger() on a non-object in D: \workspace\cv_cake\cake\libs\model\model.php on line 1780 After digging inside Cake Core I found source of this error: [42] = Array ( [file] = D:\workspace\cv_cake\cake\libs\model\model.php [line] = 702 [function] = cakeError [class] = Object [object] = CoreAccount Object [...] [args] = Array ( [0] = missingTable [1] = Array ( [0] = Array ( [className] = CoreAccount [table] = test_suite_accounts ) ) ) ) But fixture is exptected to create such table... Any ideas? Reagrds Michał Bachowski --~--~-~--~~~---~--~~ 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 woes (cake_1.2.0.7296-rc2)
PS: Things _do_ work if I specify the fields explicitly ... I was mistakenly using find('list', array('bid_session_id','user_id')) instead of find('list', array('fields' = array('bid_session_id','user_id'))) ... [well, Model::find() does have the signature find($conditions = null, $fields = array(), $order = null, $recursive = null) :)]. Anyway ... but why doesn't $this-User-BidSessionRegistration- find('list') work?! On Aug 20, 9:46 am, eleven10 [EMAIL PROTECTED] wrote: Good observation! I had somehow missed the missing backtick ... another thing for which I don't understand ... I know it _has_ to be something subtle, but I just can't get my finger on it ... Anyway, here are the model classes (I have just removed some of the option keys from the auto-generated stuff): user.php: ?php class User extends AppModel { var $name = 'User'; var $validate = array( 'login' = array('alphanumeric'), 'points' = array('numeric') ); var $hasMany = 'Bid'; var $hasAndBelongsToMany = array( 'BidSession' = array('joinTable' = 'bid_session_registrations') ); } ? bid_session.php ?php class BidSession extends AppModel { var $name = 'BidSession'; var $validate = array( 'title' = array('alphanumeric'), 'cap' = array('numeric')//, //'starts_at' = array('date'), //'ends_at' = array('date') ); var $hasMany = 'Bid'; var $hasAndBelongsToMany = array( 'User' = array('joinTable' = 'bid_session_registrations') ); } ? bid.php ?php class Bid extends AppModel { var $name = 'Bid'; var $validate = array( 'bid_points' = array('numeric') ); var $belongsTo = array('User', 'BidSession'); } ? It doesn't help even if I specify the 'foreignKey' and 'associationForeignKey' in the HABTM relationship. As a quick-and-dirty debug, I put the line pr($query); in Model::find() [CORE\cake\libs\model\model.php] just before the call to $db-read($this, $query); on line 1795. This is what I get (url: / users/add): Array ( [conditions] = [fields] = Array ( [0] = BidSessionRegistration.user_id [1] = BidSessionRegistration. ) [joins] = Array ( ) [limit] = [offset] = [order] = Array ( [0] = ) [page] = 1 [group] = [callbacks] = 1 [recursive] = -1 [list] = Array ( [groupPath] = [valuePath] = {n}.BidSessionRegistration. [keyPath] = {n}.BidSessionRegistration.user_id ) ) In the docs for Model::find() it's written that: * Specifying 'fields' for new-notation 'list': * - If no fields are specified, then 'id' is used for key and 'model-displayField' is used for value. * - If a single field is specified, 'id' is used for key and specified field is used for value. * - If three fields are specified, they are used (in order) for key, value and group. * - Otherwise, first and second fields are used for key and value. So I modified the auto-generated $this-User-BidSessionRegistration-find('list') call in users_controller.php by explicitly specifying the fields as array('bid_session_id', 'user_id') ... still, no improvement. Now I changed the bid_session_registrations table by removing PK (bid_session_id, user_id) and adding an id field (although I guess there's no need to do that for join tables that are not separately modeled...). Now, the debug output reads: Array ( [conditions] = [fields] = Array ( [0] = BidSessionRegistration.id [1] = BidSessionRegistration.id ) . . . [list] = Array ( [groupPath] = [valuePath] = {n}.BidSessionRegistration.id [keyPath] = {n}.BidSessionRegistration.id ) ) But this is not what I want... Also, I have no clue why the bake script related User to BidSessionRegistration not BidSession in /user/add... Sorry for the long post, but I am really confused why things are happening the way they are. Thanks for all the help! On Aug 20, 3:47 am, MonkeyGirl [EMAIL PROTECTED] wrote: (a) If I go to /users/add, I get the following SQL error: 1064: You have an error in your SQL syntax; ... near 'bid_session_registrations` AS `BidSessionRegistration` WHERE 1 = 1' at line 1 [CORE\cake\libs \model\datasources\dbo_source.php, line 512]. Query: SELECT `BidSessionRegistration`.`user_id`, BidSessionRegistration`. FROM `bid_session_registrations` AS `BidSessionRegistration` WHERE 1 = 1. Note the missing field name before 'FROM'. This table has PK (bid_session_id, user_id). If I remove that and add an id field as PK, things start working. However,
Re: HABTM woes (cake_1.2.0.7296-rc2)
I tried your suggestion, no changes ... However, var $hasMany = 'Bid' also works ... as the output from pr($this-User-hasMany) in UsersController shows: Array ( [Bid] = Array ( [className] = Bid [foreignKey] = user_id [conditions] = [fields] = [order] = [limit] = [offset] = [dependent] = [exclusive] = [finderQuery] = [counterQuery] = ) ) I think if $hasMany is a string Cake converts it to an array first ... As I said earlier, explicitly stating the fields [i.e., $this-User- BidSessionRegistration-find('list', array('fields' = array('bid_session_id','user_id')));] works, but $this-User- BidSessionRegistration-find('list') doesn't, not sure why, but I suspect it has something to do with this line in the docs: If no fields are specified, then 'id' is used for key and 'model- displayField' is used for value. But what puzzles me more is the fact that the bake script correctly picked up the relation between BidSession and User but not between User and BidSession. Somehow it came to the conclusion that User is related more to BidSessionRegistration and so included code to list BidSessionRegistrations for new users instead of listing BidSessions. On Aug 20, 3:52 pm, MonkeyGirl [EMAIL PROTECTED] wrote: var $hasMany = 'Bid'; I could be wrong here, but I *think* that this has to be an array, even if there's only one item in it. As in: var $hasMany = array( 'Bid' = array( 'className' = 'Bid' ) ); Does updating that help at all? Zoe. --~--~-~--~~~---~--~~ 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: OrderedBehavior - Order your lists in a TreeBehavior like manner, but only for one level.
I propose we should think of how we can use the Bakery to become our ultimate resource for articles. I have a couple of simple ideas and if anyone is also interested, I'll start a thread about this topic so we can give positive feedback, ideas and encouragement to the Bakery developers which they can bear in mind if they plan any future improvements. Maybe it's not that clear for everyone that things should be done the CakePhp's way. Perhaps a How To Post To Bakery would be very usefull! Even to editors so that they wouldn't have to spend time with messed code and crappy tips. --~--~-~--~~~---~--~~ 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 woes (cake_1.2.0.7296-rc2)
Hi Jon, Nope, your can not use composite keys with cakephp, you have to have an ID (or a field that you use as the primary, auto-incrementing id) - search the group for more background on this. I was under the impression that habtm join tables don't need to have a separate 'id' PK if you're not going to have a Model for it ... the manual also states that The contents of the table should be at least two fields, each foreign keys (which should be integers) pointing to both of the primary keys of the involved models. Anyway, as I said earlier, I also used a modified table with an id field ... in this case find() generates the SQL query SELECT `BidSessionRegistration`.`id` FROM `bid_session_registrations` AS `BidSessionRegistration` WHERE 1 = 1, but shouldn't the code be querying for user_id and bid_session_id? What _does_ help is explicitly passing the query fields, like so: $this-User-BidSessionRegistration-find('list', array('fields' = array('bid_session_id','user_id'))) ... but why shouldn't $this-User- BidSessionRegistration-find('list') work? That is more intuitive ... and that is why I wonder where I am making a mistake! make sure you define your associations in alphabetical order, scaffolding can be quite picky about that (least it was last time I used it, though that was some time ago!). I am not sure I get your point ... are you talking about the order of defining models in the bake script? (I defined them in the order BidSession, User, Bid) ... or should I be looking in the respective model classes? I know I am breaking the naming convention for the habtm join table, but in this case the name 'registrations' sounds better ... and I have mentioned the joinTable in both the User and BidSession models ... Thanks for your help! --~--~-~--~~~---~--~~ 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 cascading delete
Why dont you just do it in the way it was supposed to be? By adding referential integrity to the database. For example: FOREIGN KEY (tablename_id) REFERENCES tablename ON DELETE CASCADE On Aug 20, 8:50 am, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need to delete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when i delete table record 1 i want to delete the relationship with table and the table 2 record as well but when i delete from table 2 i want to keep table 1 record is there any feature in cakephp for cascading in habtm? --~--~-~--~~~---~--~~ 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 cascading delete
Why don't you just do it the way its suppossed to be? By adding referential integrity to the database. For example: CREATE TABLE / ALTER TABLE ... ... FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON DELETE CASCADE; On Aug 20, 9:21 am, Marcello [EMAIL PROTECTED] wrote: the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need todelete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when ideletetable record 1 i want todeletethe relationship with table and the table 2 record as well but when ideletefrom table 2 i want to keep table 1 record is there any feature in cakephp forcascadingin habtm? --~--~-~--~~~---~--~~ 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 handle multiple gaming categories?
Sounds like a plan you da man 3 On Aug 19, 4:48 pm, Adrian [EMAIL PROTECTED] wrote: I'm doing something similar. If you look towards the bottom of that link there is a section about prefixes. So your routes look like Router::connect('/wow/:controller/:action'); What I'm doing is in the controllers I have an action that takes care of all the generic logic that can't be accessed by the users: function _sell() { //some code here that uses $this-game } Then other publicly accessible functions for each category that set the category flag and then call the generic function: function wow_sell(){ $this-game = 'wow'; $this-_generic(); } This way you have all code that is generic the same for each call in one location and the specific actions just set the proper flag. Hope this helps. On Aug 19, 4:16 pm, rocket [EMAIL PROTECTED] wrote: i thought i relpied to tis is there a delay? test On Aug 19, 3:03 pm, teknoid [EMAIL PROTECTED] wrote: Should be easily handled with routes...http://book.cakephp.org/view/46/routes-configuration There are some good tutorials out there as well. On Aug 19, 12:28 pm, rocket [EMAIL PROTECTED] wrote: hello i'm building a trading post for my two favorite games, WoW and Ultima Online, but i'm not sure how to handle categories. It will be a common buy/selll/trade pos. Ideally URLs would look like this: www.tradingpost.com/wow/www.tradingpost.com/uo/ I know I can create separate folders to do this in the controller, wow and uo respectivley, but then if i do something like this www.tradingpost.com/wow/sellwww.tradingpost.com/uo/sell How do I just share the sell controller between them, and rely on the wow/uo section of the URL to declare the category ID for my SQL database? does anyone have any tips? 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 -~--~~~~--~~--~--~---
Multiple Inserts without a loop
So it seems most implementations of active record I've used have NOT had a way to do this, so I guess I'm hoping Cake is above the curve here... I'd like the general ability to do N record inserts (and updates) without doing N database calls. Essentially, I want something of the form: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); I'd like to do this without writing custom sql. Ideally I'd like to do this elegantly with associated models in one save(). If I have a Exam model that hasMany Questions, I'd like to do the following: $this-data['Exam']['title'] = 'Midterm Exam'; $this-data['Exam']['user_id'] = 'kls93mklj03m9d'; $this-data['Question'][0]['question_txt'] = Question one text; $this-data['Question'][1]['question_txt'] = Question two text; $this-Exam-create(); $this-Exam-save($this-data); The way I imagine this would work is actually using two inserts, as you would need the insert id of Exam to be added to each Question. Ok, so clearly this isn't trivial, but it also seems extremely useful. Did someone already implement this, or come up with a relatively elegant hack? Should I be posting this in the feature request for cake instead of here? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HABTM without middle table
Is this possible with a HABTM? I have two types of tables and one notes table that can be used for multiple tables. ie: quotes ( id customer_id due_date note_group_id created_date created_by ) items( id item_num desc price note_group_id ) notes ( id note_group_id note created_date created_by ) The join would be from note_group_id in either items or quotes to the note_group_id on the notes table. The note_group_id would be managed by the code to ensure that they were unique (either using guid's or checking for null values, finding the max value of the note_group_id in the notes table and incrementing it) I have a feeling that the HABTM uses the primary key of each of the tables as a join to a middle table, but was wondering if anyone had any experience with this scenario. thanks, David --~--~-~--~~~---~--~~ 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: Multiple Inserts without a loop
use saveAll() to store multiple records On Aug 20, 12:55 pm, seth [EMAIL PROTECTED] wrote: So it seems most implementations of active record I've used have NOT had a way to do this, so I guess I'm hoping Cake is above the curve here... I'd like the general ability to do N record inserts (and updates) without doing N database calls. Essentially, I want something of the form: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); I'd like to do this without writing custom sql. Ideally I'd like to do this elegantly with associated models in one save(). If I have a Exam model that hasMany Questions, I'd like to do the following: $this-data['Exam']['title'] = 'Midterm Exam'; $this-data['Exam']['user_id'] = 'kls93mklj03m9d'; $this-data['Question'][0]['question_txt'] = Question one text; $this-data['Question'][1]['question_txt'] = Question two text; $this-Exam-create(); $this-Exam-save($this-data); The way I imagine this would work is actually using two inserts, as you would need the insert id of Exam to be added to each Question. Ok, so clearly this isn't trivial, but it also seems extremely useful. Did someone already implement this, or come up with a relatively elegant hack? Should I be posting this in the feature request for cake instead of here? --~--~-~--~~~---~--~~ 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 handle multiple gaming categories?
Wait sorry. Is generic() some built in feature? I don't quite get it o_O. On Aug 19, 4:48 pm, Adrian [EMAIL PROTECTED] wrote: I'm doing something similar. If you look towards the bottom of that link there is a section about prefixes. So your routes look like Router::connect('/wow/:controller/:action'); What I'm doing is in the controllers I have an action that takes care of all the generic logic that can't be accessed by the users: function _sell() { //some code here that uses $this-game } Then other publicly accessible functions for each category that set the category flag and then call the generic function: function wow_sell(){ $this-game = 'wow'; $this-_generic(); } This way you have all code that is generic the same for each call in one location and the specific actions just set the proper flag. Hope this helps. On Aug 19, 4:16 pm, rocket [EMAIL PROTECTED] wrote: i thought i relpied to tis is there a delay? test On Aug 19, 3:03 pm, teknoid [EMAIL PROTECTED] wrote: Should be easily handled with routes...http://book.cakephp.org/view/46/routes-configuration There are some good tutorials out there as well. On Aug 19, 12:28 pm, rocket [EMAIL PROTECTED] wrote: hello i'm building a trading post for my two favorite games, WoW and Ultima Online, but i'm not sure how to handle categories. It will be a common buy/selll/trade pos. Ideally URLs would look like this: www.tradingpost.com/wow/www.tradingpost.com/uo/ I know I can create separate folders to do this in the controller, wow and uo respectivley, but then if i do something like this www.tradingpost.com/wow/sellwww.tradingpost.com/uo/sell How do I just share the sell controller between them, and rely on the wow/uo section of the URL to declare the category ID for my SQL database? does anyone have any tips? 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 woes (cake_1.2.0.7296-rc2)
Hi amitava, Nope, your can not use composite keys with cakephp, you have to have an ID (or a field that you use as the primary, auto-incrementing id) - search the group for more background on this. I was under the impression that habtm join tables don't need to have a separate 'id' PK if you're not going to have a Model for it ... the manual also states that The contents of the table should be at least two fields, each foreign keys (which should be integers) pointing to both of the primary keys of the involved models. yes, but ALL tables have to have an auto incrementing field as well, so you need: id foreign_key foreign_key Anyway, as I said earlier, I also used a modified table with an id field ... in this case find() generates the SQL query SELECT `BidSessionRegistration`.`id` FROM `bid_session_registrations` AS `BidSessionRegistration` WHERE 1 = 1, but shouldn't the code be querying for user_id and bid_session_id? What _does_ help is explicitly passing the query fields, like so: $this-User-BidSessionRegistration-find('list', array('fields' = array('bid_session_id','user_id'))) ... but why shouldn't $this-User- BidSessionRegistration-find('list') work? That is more intuitive ... and that is why I wonder where I am making a mistake! I'm really struggling to follow your code in gmail, could you post your models, controller and view to http://bin.cakephp.org/add/eleven10 - might help to get you DB as well. make sure you define your associations in alphabetical order, scaffolding can be quite picky about that (least it was last time I used it, though that was some time ago!). I am not sure I get your point ... are you talking about the order of defining models in the bake script? (I defined them in the order BidSession, User, Bid) ... or should I be looking in the respective model classes? I know I am breaking the naming convention for the habtm join table, but in this case the name 'registrations' sounds better ... and I have mentioned the joinTable in both the User and BidSession models ... sorry, I didn't mean alphabetical order - I mean this. You have to make the sure the order of your foreign keys matches the order of association declarations in your model classes. Also, it's much easier to stick to the conventions... cheers, jon -- 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: Newbie of Cake Php : Problems with Vista Installation and First Application
thanks for your detailed help I tried the following for a specific directory im not as you say using user directories i guess from your description... Directory /www/fb00/ Options Indexes Includes FollowSymLinks AllowOverride All Order allow,deny Allow from all /Directory I took out the rewrite base line and it still doesn't work always the same error..Is there some radical test I can do to give me better debug ? I have other sites (folders) using mod rewrite ok thanks already --~--~-~--~~~---~--~~ 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 handle multiple gaming categories?
I would do it like this: Router::connect('/:cat/sells', array('controller' = 'sells', 'action' = 'index'), array('cat' = 'wow|uo')); Now you can access: domain.com/wow/sells domain.com/uo/sells in your controller's action you can check $this-params['cat'] which will contain either wow or uo. On 20 Aug., 19:29, rocket [EMAIL PROTECTED] wrote: Wait sorry. Is generic() some built in feature? I don't quite get it o_O. On Aug 19, 4:48 pm, Adrian [EMAIL PROTECTED] wrote: I'm doing something similar. If you look towards the bottom of that link there is a section about prefixes. So your routes look like Router::connect('/wow/:controller/:action'); What I'm doing is in the controllers I have an action that takes care of all the generic logic that can't be accessed by the users: function _sell() { //some code here that uses $this-game } Then other publicly accessible functions for each category that set the category flag and then call the generic function: function wow_sell(){ $this-game = 'wow'; $this-_generic(); } This way you have all code that is generic the same for each call in one location and the specific actions just set the proper flag. Hope this helps. On Aug 19, 4:16 pm, rocket [EMAIL PROTECTED] wrote: i thought i relpied to tis is there a delay? test On Aug 19, 3:03 pm, teknoid [EMAIL PROTECTED] wrote: Should be easily handled with routes...http://book.cakephp.org/view/46/routes-configuration There are some good tutorials out there as well. On Aug 19, 12:28 pm, rocket [EMAIL PROTECTED] wrote: hello i'm building a trading post for my two favorite games, WoW and Ultima Online, but i'm not sure how to handle categories. It will be a common buy/selll/trade pos. Ideally URLs would look like this: www.tradingpost.com/wow/www.tradingpost.com/uo/ I know I can create separate folders to do this in the controller, wow and uo respectivley, but then if i do something like this www.tradingpost.com/wow/sellwww.tradingpost.com/uo/sell How do I just share the sell controller between them, and rely on the wow/uo section of the URL to declare the category ID for my SQL database? does anyone have any tips? 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: how to handle multiple gaming categories?
i will try this. it seems like the exact soln. i was looking for. ill let you know how ti goes! :) On Aug 20, 3:14 pm, biesbjerg [EMAIL PROTECTED] wrote: I would do it like this: Router::connect('/:cat/sells', array('controller' = 'sells', 'action' = 'index'), array('cat' = 'wow|uo')); Now you can access: domain.com/wow/sells domain.com/uo/sells in your controller's action you can check $this-params['cat'] which will contain either wow or uo. On 20 Aug., 19:29, rocket [EMAIL PROTECTED] wrote: Wait sorry. Is generic() some built in feature? I don't quite get it o_O. On Aug 19, 4:48 pm, Adrian [EMAIL PROTECTED] wrote: I'm doing something similar. If you look towards the bottom of that link there is a section about prefixes. So your routes look like Router::connect('/wow/:controller/:action'); What I'm doing is in the controllers I have an action that takes care of all the generic logic that can't be accessed by the users: function _sell() { //some code here that uses $this-game } Then other publicly accessible functions for each category that set the category flag and then call the generic function: function wow_sell(){ $this-game = 'wow'; $this-_generic(); } This way you have all code that is generic the same for each call in one location and the specific actions just set the proper flag. Hope this helps. On Aug 19, 4:16 pm, rocket [EMAIL PROTECTED] wrote: i thought i relpied to tis is there a delay? test On Aug 19, 3:03 pm, teknoid [EMAIL PROTECTED] wrote: Should be easily handled with routes...http://book.cakephp.org/view/46/routes-configuration There are some good tutorials out there as well. On Aug 19, 12:28 pm, rocket [EMAIL PROTECTED] wrote: hello i'm building a trading post for my two favorite games, WoW and Ultima Online, but i'm not sure how to handle categories. It will be a common buy/selll/trade pos. Ideally URLs would look like this: www.tradingpost.com/wow/www.tradingpost.com/uo/ I know I can create separate folders to do this in the controller, wow and uo respectivley, but then if i do something like this www.tradingpost.com/wow/sellwww.tradingpost.com/uo/sell How do I just share the sell controller between them, and rely on the wow/uo section of the URL to declare the category ID for my SQL database? does anyone have any tips? 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: how to handle multiple gaming categories?
i will try this. it seems like the exact soln. i was looking for. ill let you know how ti goes! :) On Aug 20, 3:14 pm, biesbjerg [EMAIL PROTECTED] wrote: I would do it like this: Router::connect('/:cat/sells', array('controller' = 'sells', 'action' = 'index'), array('cat' = 'wow|uo')); Now you can access: domain.com/wow/sells domain.com/uo/sells in your controller's action you can check $this-params['cat'] which will contain either wow or uo. On 20 Aug., 19:29, rocket [EMAIL PROTECTED] wrote: Wait sorry. Is generic() some built in feature? I don't quite get it o_O. On Aug 19, 4:48 pm, Adrian [EMAIL PROTECTED] wrote: I'm doing something similar. If you look towards the bottom of that link there is a section about prefixes. So your routes look like Router::connect('/wow/:controller/:action'); What I'm doing is in the controllers I have an action that takes care of all the generic logic that can't be accessed by the users: function _sell() { //some code here that uses $this-game } Then other publicly accessible functions for each category that set the category flag and then call the generic function: function wow_sell(){ $this-game = 'wow'; $this-_generic(); } This way you have all code that is generic the same for each call in one location and the specific actions just set the proper flag. Hope this helps. On Aug 19, 4:16 pm, rocket [EMAIL PROTECTED] wrote: i thought i relpied to tis is there a delay? test On Aug 19, 3:03 pm, teknoid [EMAIL PROTECTED] wrote: Should be easily handled with routes...http://book.cakephp.org/view/46/routes-configuration There are some good tutorials out there as well. On Aug 19, 12:28 pm, rocket [EMAIL PROTECTED] wrote: hello i'm building a trading post for my two favorite games, WoW and Ultima Online, but i'm not sure how to handle categories. It will be a common buy/selll/trade pos. Ideally URLs would look like this: www.tradingpost.com/wow/www.tradingpost.com/uo/ I know I can create separate folders to do this in the controller, wow and uo respectivley, but then if i do something like this www.tradingpost.com/wow/sellwww.tradingpost.com/uo/sell How do I just share the sell controller between them, and rely on the wow/uo section of the URL to declare the category ID for my SQL database? does anyone have any tips? 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: parameter 0 in requestAction do not work
Hi Klaus, Try $this-requestAction(array('controller'='repairs', 'action'='getData'), array('pass' = array(0))); On 18 Aug., 11:11, Klaus Schwarzkopf [EMAIL PROTECTED] wrote: Hi, i use the requestAction funktion with a parameter. The value of the parameter is 0. My cake version is 1.2.0.7296 RC2. Controller: $action='/repairs/getData/0'; $this-set('repairs', $this-requestAction($action)); I get this error: Warning (2): Missing argument 1 for RepairsController::getData(), called in /var/www/auftragnew/cake/cake/libs/object.php on line 115 and defined [APP/controllers/repairs_controller.php, line 22] Code function getData($id) RepairsController::getData() - APP/controllers/repairs_controller.php, line 22 Object::dispatchMethod() - CORE/cake/libs/object.php, line 115 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 261 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 234 Object::requestAction() - CORE/cake/libs/object.php, line 99 OrdersController::view() - APP/controllers/orders_controller.php, line 652 Object::dispatchMethod() - CORE/cake/libs/object.php, line 117 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 261 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 234 [main] - APP/webroot/index.php, line 90 This function call does not work, too. $this-requestAction(array('controller'='repairs', 'action'='getData', 0)); Thanks Klaus --~--~-~--~~~---~--~~ 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: Newbie of Cake Php : Problems with Vista Installation and First Application
Hi What error do you get exactly ? What happens when you point your browser to http://localhost/ ? Clément On Wed, Aug 20, 2008 at 9:12 PM, www.landed.at [EMAIL PROTECTED] wrote: thanks for your detailed help I tried the following for a specific directory im not as you say using user directories i guess from your description... Directory /www/fb00/ Options Indexes Includes FollowSymLinks AllowOverride All Order allow,deny Allow from all /Directory I took out the rewrite base line and it still doesn't work always the same error..Is there some radical test I can do to give me better debug ? I have other sites (folders) using mod rewrite ok thanks already --~--~-~--~~~---~--~~ 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 cascading delete
im a little new to referential integrity in the database directly, could you enligthen me? i got 5 tables Clients AddressClient Addresses Sellers AddressSeller what i need is, when i delete a client or a seller, it should also delete his addresses, BUT when i delete a address the client or seller must remain untouched On 20 ago, 12:45, nachopitt [EMAIL PROTECTED] wrote: Why don't you just do it the way its suppossed to be? By adding referential integrity to the database. For example: CREATE TABLE / ALTER TABLE ... ... FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON DELETE CASCADE; On Aug 20, 9:21 am, Marcello [EMAIL PROTECTED] wrote: the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need todelete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when ideletetable record 1 i want todeletethe relationship with table and the table 2 record as well but when ideletefrom table 2 i want to keep table 1 record is there any feature in cakephp forcascadingin habtm? --~--~-~--~~~---~--~~ 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 cascading delete
That will only work if your database engine supports foreign key constraints, such as MySQL InnoDB. The default MySQL MyISAM engine does not support any type of referential integrity; you can set the FOREIGN KEY/REFERENCES attributes, but they will be ignored. Other database implementations may also be lacking foreign key constraints, but my experience is localized to PostgreSQL and MySQL. It's probably worth opening up a ticket concerning your issue, since one would expect that the default behaviour for 'dependent' would allow the deletion of the associated entry in the join table, effectively unlinking the two model records in question. I agree with Dave, however, in that in most cases you would not want to delete the associated records in a HABTM relationship (as opposed to the entry in the join table) for obvious reasons. -Joel. On Aug 20, 5:12 pm, Marcello [EMAIL PROTECTED] wrote: im a little new to referential integrity in the database directly, could you enligthen me? i got 5 tables Clients AddressClient Addresses Sellers AddressSeller what i need is, when i delete a client or a seller, it should also delete his addresses, BUT when i delete a address the client or seller must remain untouched On 20 ago, 12:45, nachopitt [EMAIL PROTECTED] wrote: Why don't you just do it the way its suppossed to be? By adding referential integrity to the database. For example: CREATE TABLE / ALTER TABLE ... ... FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON DELETE CASCADE; On Aug 20, 9:21 am, Marcello [EMAIL PROTECTED] wrote: the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need todelete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when ideletetable record 1 i want todeletethe relationship with table and the table 2 record as well but when ideletefrom table 2 i want to keep table 1 record is there any feature in cakephp forcascadingin habtm? --~--~-~--~~~---~--~~ 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: Newbie of Cake Php : Problems with Vista Installation and First Application
GOT IT TO WORK BUT IS IT SECURE ? I placed Options +FollowSymLinks in the .htaccess file in the root of my cake install ! but why does this work, and should I use it like 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 -~--~~~~--~~--~--~---
Re: Acl and Auth slow page load
Index your aco table on alias ... On Aug 19, 1:15 am, Marcus J. Ertl [EMAIL PROTECTED] wrote: Marcus J. Ertl schrieb: Hi again! I'm afraid, this is poor application design on my side too. :-( OK, I took a look into this! It was bad design on my side! :-( I've startet with more then 60 queries, taking about 30 seconds! :-( After taking the check outside the loop, I'm down to 24 queries, taking about 10 seconds. Adding indexes to the acos- and aros-tables brought down the time for this queries to about 2 seconds! A closer look shows, it's allways the same query taking to long: *23. Affected: 36 Num. rows: 36 Took: 502ms* SELECT `Aco`.`id`, `Aco`.`parent_id`, `Aco`.`model`, `Aco`.`foreign_key`, `Aco`.`alias` FROM `acos` AS `Aco` LEFT JOIN `acos` AS `Aco0` ON (`Aco0`.`alias` = 'links') LEFT JOIN `acos` AS `Aco1` ON (`Aco1`.`lft` `Aco0`.`lft` AND `Aco1`.`rght` `Aco0`.`rght` AND `Aco1`.`alias` = 'mod_edit') WHERE ((`Aco`.`lft` = `Aco0`.`lft` AND `Aco`.`rght` = `Aco0`.`rght`) OR (`Aco`.`lft` = `Aco1`.`lft` AND `Aco`.`rght` = `Aco1`.`rght`)) ORDER BY `Aco`.`lft` DESC This is not perfekt, but I can life with this values. But it would be nice, if I could get this querys down in time too! Will be there some acl-caching as core feature in cakephp 1.2? Or have I to do it by myself? Thank you very much! Bye Marcus smime.p7s 4KViewDownload --~--~-~--~~~---~--~~ 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: Multiple Inserts without a loop
Right, but how many inserts does this perform? And does the auto- magic know to use the Exam's newly created id? -seth On Aug 20, 10:36 am, teknoid [EMAIL PROTECTED] wrote: use saveAll() to store multiple records On Aug 20, 12:55 pm, seth [EMAIL PROTECTED] wrote: So it seems most implementations of active record I've used have NOT had a way to do this, so I guess I'm hoping Cake is above the curve here... I'd like the general ability to do N record inserts (and updates) without doing N database calls. Essentially, I want something of the form: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); I'd like to do this without writing custom sql. Ideally I'd like to do this elegantly with associated models in one save(). If I have a Exam model that hasMany Questions, I'd like to do the following: $this-data['Exam']['title'] = 'Midterm Exam'; $this-data['Exam']['user_id'] = 'kls93mklj03m9d'; $this-data['Question'][0]['question_txt'] = Question one text; $this-data['Question'][1]['question_txt'] = Question two text; $this-Exam-create(); $this-Exam-save($this-data); The way I imagine this would work is actually using two inserts, as you would need the insert id of Exam to be added to each Question. Ok, so clearly this isn't trivial, but it also seems extremely useful. Did someone already implement this, or come up with a relatively elegant hack? Should I be posting this in the feature request for cake instead of here? --~--~-~--~~~---~--~~ 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: Newbie of Cake Php : Problems with Vista Installation and First Application
Weird. The Options parameter is better explained here (especially the + stuff): http://httpd.apache.org/docs/2.2/mod/core.html#options Your httpd.conf file may contain several encapsuled Directories that have options which interfere with the other (not sure if this sentence is clear, but it's late here). Maybe you could post your full httpd.conf, because it probably needs a little cleaning... Maybe you can do this off-list, as it's becoming less and less related to Cake itself, and also quite specific to your setup, and thus not very useful to share and archive. ++ Clément On Wed, Aug 20, 2008 at 11:29 PM, www.landed.at [EMAIL PROTECTED] wrote: GOT IT TO WORK BUT IS IT SECURE ? I placed Options +FollowSymLinks in the .htaccess file in the root of my cake install ! but why does this work, and should I use it like 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 -~--~~~~--~~--~--~---
Re: Multiple Inserts without a loop
Right, but how many inserts does this perform? - As many inserts as required And does the auto-magic know to use the Exam's newly created id? - Yes On Aug 20, 5:37 pm, seth [EMAIL PROTECTED] wrote: Right, but how many inserts does this perform? And does the auto- magic know to use the Exam's newly created id? -seth On Aug 20, 10:36 am, teknoid [EMAIL PROTECTED] wrote: use saveAll() to store multiple records On Aug 20, 12:55 pm, seth [EMAIL PROTECTED] wrote: So it seems most implementations of active record I've used have NOT had a way to do this, so I guess I'm hoping Cake is above the curve here... I'd like the general ability to do N record inserts (and updates) without doing N database calls. Essentially, I want something of the form: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); I'd like to do this without writing custom sql. Ideally I'd like to do this elegantly with associated models in one save(). If I have a Exam model that hasMany Questions, I'd like to do the following: $this-data['Exam']['title'] = 'Midterm Exam'; $this-data['Exam']['user_id'] = 'kls93mklj03m9d'; $this-data['Question'][0]['question_txt'] = Question one text; $this-data['Question'][1]['question_txt'] = Question two text; $this-Exam-create(); $this-Exam-save($this-data); The way I imagine this would work is actually using two inserts, as you would need the insert id of Exam to be added to each Question. Ok, so clearly this isn't trivial, but it also seems extremely useful. Did someone already implement this, or come up with a relatively elegant hack? Should I be posting this in the feature request for cake instead of here? --~--~-~--~~~---~--~~ 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: Multiple Inserts without a loop
Right, but how many inserts does this perform? - As many inserts as required Yes, but my whole point is that if you are inserting 1000 questions, this could be done in 2 interests or 1001... Is cake currently smart enough to do it in 2? --~--~-~--~~~---~--~~ 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: Help with Model:find()
On Aug 18, 8:43 am, Jon Bennett [EMAIL PROTECTED] wrote: ... a far easier solution to the problem would be to store an interger for the status, you could assign things like so: 0 - unpaid/unprocessed 1 - paid/processed 2 - dispatched 3 - refunded Before I finally discovered that there were replies to my question :)I did end up going with a similar solution in order to avoid hackiness. Which actually brings me to another question: Should the following work?: Account has many Purchase Purchase belongs to Account $this-Account-id = 1; $this-Account-read(); $this-Account-Purchases-find('unpaid'); From Purchases model (overriding find method taken from http://c7y.phparch.com/c/entry/1/art,mvc_and_cake): function find($type, { ... case 'unpaid': $params = array_merge($params, array('conditions' = array('Purchase.status' = 'pending'))); return parent::find('all', $params); ... } My hopes were that the above would produce the following SQL (it does not): SELECT Purchase.* FROM purchases AS Purchase LEFT JOIN accounts AS Account ON (Account.id = Purchase.account_id) WHERE Purchase.status = 'pending' AND Account.id = 1; --~--~-~--~~~---~--~~ 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: Multiple Inserts without a loop
On Wed, Aug 20, 2008 at 5:51 PM, seth [EMAIL PROTECTED] wrote: Right, but how many inserts does this perform? - As many inserts as required Yes, but my whole point is that if you are inserting 1000 questions, this could be done in 2 interests or 1001... Is cake currently smart enough to do it in 2? If you set debug in config/core.php to 1 or greater you can see this for yourself. You'll see all the SQL calls. Or, if you're feeling really adventurous, you could actually build the damn thing and see if it matters. I'm willing to bet that it won't matter to your application's performance whether it's 2 or 1000. If it *does* matter, then congratulations are in order because you've built an application with more users than 99% of CakePHP apps out there and you will have other problems not related to Cake to worry about. -- Chris Hartjes Motto for 2008: Moving from herding elephants to handling snakes... @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ 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: Multiple Inserts without a loop
AFAIK, the syntax you are proposing is MySQL (or at least DB vendor) specific. So, it won't be supported by cake. And do you really insert 1001 rows? On Aug 20, 5:51 pm, seth [EMAIL PROTECTED] wrote: Right, but how many inserts does this perform? - As many inserts as required Yes, but my whole point is that if you are inserting 1000 questions, this could be done in 2 interests or 1001... Is cake currently smart enough to do it in 2? --~--~-~--~~~---~--~~ 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: Help with Model:find()
Hi lauren, Before I finally discovered that there were replies to my question :)I did end up going with a similar solution in order to avoid hackiness. Which actually brings me to another question: Should the following work?: Account has many Purchase Purchase belongs to Account $this-Account-id = 1; $this-Account-read(); $this-Account-Purchases-find('unpaid'); there's no 'magic' method called 'unpaid', there's only: first - grabs a single record all - grabs all records threaded - grabs a simple tree list - gets a name/value pair array what you want to do is easy though, with a single call, try: $this-Account-Behaviors-attach('Containable'); $account = $this-Account-find('first', array( 'conditions'=array('Account.id' = $account_id), 'contain'=array( 'Payment'=array('conditions'=array( 'Payment.status'='pending' ))) )); hth jon -- 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: Is this a crazy phbBB3 CakePHP idea?
Yeah that was my plan, and how I have executed it. Seems to be working well, especially with Containable there to really target exactly what I want returned. Add to that the caching engine and I reckon this is gonna be a nice little bridge between my site and my forums. If by any chance anyone else fancies doin this and wants a headstart just ask and I'll stick the files up somewhere, but in all honesty once you figure out PhpBB's DB naming conventions and relationships its a doddle. I'm not bothering tryin to integrate log in/out tho - far too much work for a 'cute' feature... ;-) t. On Aug 20, 12:36 am, rtconner [EMAIL PROTECTED] wrote: Yes you can do that, no problem. Just gotta use the $useTable var in the models. --~--~-~--~~~---~--~~ 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: Help with Model:find()
Hi Lauren, I meant 'Purchase' not Payment! $this-Account-Behaviors-attach('Containable'); $account = $this-Account-find('first', array( 'conditions'=array('Account.id' = $account_id), 'contain'=array( 'Purchase'=array('conditions'=array( 'Purchase.status'='pending' ))) )); hth jon -- 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: Acl and Auth slow page load
francky06l schrieb: Hi! Index your aco table on alias ... I have allready done this! The results from the last mail are with this index! Bye Tiggr Indizes on acos: Name Typ KardinalitätFeld PRIMARY PRIMARY 433 id alias_index INDEX 36 alias tree_index INDEX 433 lft rght lft_index INDEX 433 lft rght_index INDEX 433 rght Indizes on aros: Name Typ KardinalitätFeld PRIMARY PRIMARY 30 id alias_index INDEX keine alias tree_index INDEX keine lft rght lft_index INDEX keine lft rght_index INDEX keine rght smime.p7s Description: S/MIME Cryptographic Signature
prefix routing and pagination
Hi! There are some bugs with prefix routing and pagination. For short: It doesn't work for other prefix routes then the admin prefix. I found a patch for this at the bug tracker (#5115), but it didn't worked for me. I've played a bit with router php and the patch, and got a version, that work's most the time for me! I don't think it is the right way to do it, but I attach the diff to this mail. It's my first diff, if it doesn't work, please tell me how to do a better one. Bye Marcus --- router.php +++ router.php @@ -779,6 +779,24 @@ unset($url[$admin]); } } + // check for prefixes that are not 'Admin.routing' + $prefixes = array(); + foreach ($_this-routes as $route) { +if (array_key_exists('prefix', $route[3])) +{ + $prefixes[$route[3]['prefix']] = $route[3]['prefix']; +} + } + foreach ($prefixes as $cur_prefix) + { +if (!isset($url[$cur_prefix]) !empty($params[$cur_prefix])) { + $url[$cur_prefix] = true; +$admin = $cur_prefix; +} elseif (isset($url[$cur_prefix]) !$url[$cur_prefix]) { + unset($url[$cur_prefix]); +} + } + $plugin = false; if (array_key_exists('plugin', $url)) { @@ -810,7 +828,10 @@ $url = $originalUrl; } $named = $args = array(); + +// ME: Prefixes berücksichtigen $skip = array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix', $admin); +if (is_array($prefixes)) $skip = array_merge($skip, $prefixes); $keys = array_values(array_diff(array_keys($url), $skip)); $count = count($keys); smime.p7s Description: S/MIME Cryptographic Signature
Re: HABTM cascading delete
Im using innoDB already and i've also explained my need to use HABTM in this case, i didnt find any better solution because i needed to shared the tables. i think i will open a ticket but still i need a solution, even if its provisory On 20 ago, 18:24, Joel Perras [EMAIL PROTECTED] wrote: That will only work if your database engine supports foreign key constraints, such as MySQL InnoDB. The default MySQL MyISAM engine does not support any type of referential integrity; you can set the FOREIGN KEY/REFERENCES attributes, but they will be ignored. Other database implementations may also be lacking foreign key constraints, but my experience is localized to PostgreSQL and MySQL. It's probably worth opening up a ticket concerning your issue, since one would expect that the default behaviour for 'dependent' would allow the deletion of the associated entry in the join table, effectively unlinking the two model records in question. I agree with Dave, however, in that in most cases you would not want to delete the associated records in a HABTM relationship (as opposed to the entry in the join table) for obvious reasons. -Joel. On Aug 20, 5:12 pm, Marcello [EMAIL PROTECTED] wrote: im a little new to referential integrity in the database directly, could you enligthen me? i got 5 tables Clients AddressClient Addresses Sellers AddressSeller what i need is, when i delete a client or a seller, it should also delete his addresses, BUT when i delete a address the client or seller must remain untouched On 20 ago, 12:45, nachopitt [EMAIL PROTECTED] wrote: Why don't you just do it the way its suppossed to be? By adding referential integrity to the database. For example: CREATE TABLE / ALTER TABLE ... ... FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON DELETE CASCADE; On Aug 20, 9:21 am, Marcello [EMAIL PROTECTED] wrote: the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need todelete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when ideletetable record 1 i want todeletethe relationship with table and the table 2 record as well but when ideletefrom table 2 i want to keep table 1 record is there any feature in cakephp forcascadingin habtm? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Cake Join is not working correctly... y ? please help
class Photocomment extends AppModel { var $name = 'Photocomment'; var $belongsTo = array('Photo' = array('className' = 'Photo', 'conditions' = '', 'order' = '', 'foreignKey' = 'photo_id' ), 'Member' = array('className' = 'Member', 'conditions' = '', 'order' = '', 'foreignKey' = 'sender_member_id' ), 'Profile' = array('className' = 'Profile', 'conditions' = array('Photocomment.sender_member_id' = 'Profile.member_id'), 'order' = '', 'foreignKey' = false ) ); } function photoview($photoId=null) { $this-pageTitle = View Photo; if ( !($photoId) || !is_numeric($photoId) ) { $this-redirect(array(controller=members, action=index),null,true); } if (empty($this-data)) { $this-Photo-unbindModel(array('hasMany' = array('Photocomment'))); $this-Photo-id = $photoId; $this-set('photoData',$this-Photo-read()); $this-Photocomment-Behaviors-attach('Containable'); $this-paginate = array( 'conditions'=array(Photocomment.photo_id = ' . $photoId . ' ), 'limit'=10, 'order'= array('Photocomment.created' = 'desc'), 'fields'= array('Photocomment.id', 'Photocomment.photo_id', 'Photocomment.sender_member_id', 'Photocomment.comments', 'Photocomment.created', 'Member.id', 'Member.fname', 'Member.lname', 'Member.email_address', 'Profile.id', 'Profile.gender', 'Profile.primaryPhotoSrc'), 'contain'= array('Member', 'Profile') ); $this-set('photoComments', $this-Paginate('Photocomment')); $this-render(); } } SELECT `Photocomment`.`id`, `Photocomment`.`photo_id`, `Photocomment`.`sender_member_id`, `Photocomment`.`comments`, `Photocomment`.`created`, `Member`.`id`, `Member`.`fname`, `Member`.`lname`, `Member`.`email_address`, `Profile`.`id`, `Profile`.`gender`, `Profile`.`primaryPhotoSrc` FROM `photocomments` AS `Photocomment` LEFT JOIN `members` AS `Member` ON (`Photocomment`.`sender_member_id` = `Member`.`id`) LEFT JOIN `profiles` AS `Profile` ON (`Photocomment`.`sender_member_id` = 'Profile.member_id') WHERE `Photocomment`.`photo_id` = '281' ORDER BY `Photocomment`.`created` desc LIMIT 10 the above outputs this: id photo_idsender_member_idcommentscreated Descending id fname lname email_address id gender primaryPhotoSrc 75 281 1 testing love of life2008-08-20 15:42:31 1 boo hoo [EMAIL PROTECTED] NULLNULLNULL 74 281 1 testing add photo comments 2008-08-20 15:33:44 1 boo hoo [EMAIL PROTECTED] NULLNULLNULL why is the profile.id,gender, and primaryPhotoSrc null? but if i manually modify the query like this: SELECT Photocomment.id, Photocomment.photo_id, Photocomment.sender_member_id, Photocomment.comments, Photocomment.created, Member.id, Member.fname, Member.lname, Member.email_address, Profile.id, Profile.gender, Profile.primaryPhotoSrc FROM profiles Profile, photocomments Photocomment, members Member WHERE Profile.member_id = Photocomment.sender_member_id AND Photocomment.sender_member_id = Member.id And Photocomment.photo_id = '281' ORDER BY Photocomment.created desc LIMIT 10 id photo_idsender_member_idcommentscreated id fname lname email_address id gender primaryPhotoSrc 75 281 1 testing love of life2008-08-20 15:42:31 1 boo hoo [EMAIL PROTECTED] 1 M 4867f8d6bac09.jpg 74 281 1 testing add photo comments 2008-08-20 15:33:44 1 boo hoo [EMAIL PROTECTED] 1 M 4867f8d6bac09.jpg
Re: HABTM cascading delete
You could simply delete the records manually, i.e. store the foreign key of the record, delete the record, then use the foreign key to delete the join entry and/or the associated record on the other end of the HABTM relation. I don't think there exists a cleaner way, but if anyone else knows, I'd be interested in hearing. -Joel. On Aug 20, 7:44 pm, Marcello [EMAIL PROTECTED] wrote: Im using innoDB already and i've also explained my need to use HABTM in this case, i didnt find any better solution because i needed to shared the tables. i think i will open a ticket but still i need a solution, even if its provisory On 20 ago, 18:24, Joel Perras [EMAIL PROTECTED] wrote: That will only work if your database engine supports foreign key constraints, such as MySQL InnoDB. The default MySQL MyISAM engine does not support any type of referential integrity; you can set the FOREIGN KEY/REFERENCES attributes, but they will be ignored. Other database implementations may also be lacking foreign key constraints, but my experience is localized to PostgreSQL and MySQL. It's probably worth opening up a ticket concerning your issue, since one would expect that the default behaviour for 'dependent' would allow the deletion of the associated entry in the join table, effectively unlinking the two model records in question. I agree with Dave, however, in that in most cases you would not want to delete the associated records in a HABTM relationship (as opposed to the entry in the join table) for obvious reasons. -Joel. On Aug 20, 5:12 pm, Marcello [EMAIL PROTECTED] wrote: im a little new to referential integrity in the database directly, could you enligthen me? i got 5 tables Clients AddressClient Addresses Sellers AddressSeller what i need is, when i delete a client or a seller, it should also delete his addresses, BUT when i delete a address the client or seller must remain untouched On 20 ago, 12:45, nachopitt [EMAIL PROTECTED] wrote: Why don't you just do it the way its suppossed to be? By adding referential integrity to the database. For example: CREATE TABLE / ALTER TABLE ... ... FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON DELETE CASCADE; On Aug 20, 9:21 am, Marcello [EMAIL PROTECTED] wrote: the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need todelete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when ideletetable record 1 i want todeletethe relationship with table and the table 2 record as well but when ideletefrom table 2 i want to keep table 1 record is there any feature in cakephp forcascadingin habtm? --~--~-~--~~~---~--~~ 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: Help with Model:find()
On Aug 20, 6:14 pm, Jon Bennett [EMAIL PROTECTED] wrote: there's no 'magic' method called 'unpaid', there's only: Yes, I know. :) I overrode the find() method in my Purchase model similar to what Nate Abele suggests in http://c7y.phparch.com/c/entry/1/art,mvc_and_cake public function find($type, $options = array()) { switch ($type) { case popular: return parent::find('all', array_merge( array( 'limit' = 10, 'order' = 'Post.view_count DESC' ), $options ); default: return parent::find($type, $options); } } However, I think the Containable Behavior is what I need. Thank you both for your help! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
User Authentication Methods
Hi all ; I am a newbie who tries to understand the basics for now . The thing is suppose that I want to build a web app which has multiple user types . Like premium member regular member admin etc . Which isthe best method to authenticate users ? ACL or the Auth component . I am aboutto solve the logic of the ACL with database . But which one would you use ? --~--~-~--~~~---~--~~ 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: Getting CakePHP to connect to MySQL
Thank you both. I decided to try installing Cake on my ISP instead of running it on my own PC. They asked me to send in photo ID before they'd let me use the system services I'd need to complete the install. Not very reassuring. So, I tried installing CodeIgniter and had it up 15 minutes after I started Googling for it. We Windows types may complain about our environment, but we are used to just downloading, installing, and running stuff. It seems normal to us. If CakePHP was anything like that it would probably rule the world. On Aug 11, 10:35 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On 23 Jun., 06:35, Jonathan Snook [EMAIL PROTECTED] wrote: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\cake \cake\libs\model\dbo\dbo_mysql.php on line 100 Make sure that you've specified the proper username and password (that's what this error message is saying). xampp uses a default u/p configuration that you may need to look up. (I remember running into a similar issue figuring out what the defaults were) I have the exact same problem and my username and everything else is correct. I don't get it. And why does it always say U440957'@'crowdie.stor' or 'vena.store' or something like that? what the hell is crowdie.stor? Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'U440957'@'crowdie.stor' (using password: YES) in /mnt/ web7/11/22/51435422/htdocs/cakephp/cake/libs/model/dbo/dbo_mysql.php on line 100 Warning: mysql_select_db(): supplied argument is not a valid MySQL- Link resource in /mnt/web7/11/22/51435422/htdocs/cakephp/cake/libs/ model/dbo/dbo_mysql.php on line 105 --~--~-~--~~~---~--~~ 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 cascading delete
Right, i forgot to tell you that. I prefer to let the RDBMS handle this, instead of having to write more code in the app. But changing from MyISAM to InnoDB can have its drawbacks. Anyway, Marcello I can see by looking at your model that you pretend to have both client and seller addresses in one table named Addresses, and thats why I suppose you are looking after a HABTM association. However, you can eliminate this association and have a pair of two hasMany and their respective belongsTo associations if you split the actual address table in two more being client_addresses and seller_addresses. I hope I was clear enough, if not please correct me. Sorry about my english, it's not my native language. On Aug 20, 4:24 pm, Joel Perras [EMAIL PROTECTED] wrote: That will only work if your database engine supports foreign key constraints, such as MySQL InnoDB. The default MySQL MyISAM engine does not support any type of referential integrity; you can set the FOREIGN KEY/REFERENCES attributes, but they will be ignored. Other database implementations may also be lacking foreign key constraints, but my experience is localized to PostgreSQL and MySQL. It's probably worth opening up a ticket concerning your issue, since one would expect that the default behaviour for 'dependent' would allow the deletion of the associated entry in the join table, effectively unlinking the two model records in question. I agree with Dave, however, in that in most cases you would not want to delete the associated records in a HABTM relationship (as opposed to the entry in the join table) for obvious reasons. -Joel. On Aug 20, 5:12 pm, Marcello [EMAIL PROTECTED] wrote: im a little new to referential integrity in the database directly, could you enligthen me? i got 5 tables Clients AddressClient Addresses Sellers AddressSeller what i need is, when i delete a client or a seller, it should also delete his addresses, BUT when i delete a address the client or seller must remain untouched On 20 ago, 12:45, nachopitt [EMAIL PROTECTED] wrote: Why don't you just do it the way its suppossed to be? By adding referential integrity to the database. For example: CREATE TABLE / ALTER TABLE ... ... FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON DELETE CASCADE; On Aug 20, 9:21 am, Marcello [EMAIL PROTECTED] wrote: the main reason for using habtm is because address table is shared among the whole system clients use them, sellers, and so on and a client can have ANY NUMBER of addresses the same for seller so i cant put a foreign key in any of the two tables thats why i must use HABTM On 20 ago, 10:50, Dave J [EMAIL PROTECTED] wrote: Not sure if I made sense in my previous post, but basically this is a case in which, if you're in a situation where you need todelete dependent records in an HABTM relationship. you might need to think if the relationship should be an HABTM one at all... or if a simpler hasMany would do the job just as well. On Aug 20, 2:44 pm, Dave J [EMAIL PROTECTED] wrote: I dont think it works for HABTM relations also for the reason that it might be unsafe to do so. By deleting all related records, you might also be deleting records which are referenced to by other entries in the join table. On Aug 20, 4:03 am, Marcello [EMAIL PROTECTED] wrote: it does not work (gives no error, but does not remove the dependent side) On 19 ago, 22:26, Marcello [EMAIL PROTECTED] wrote: dependent is exactly what i was looking for thanks! On 19 ago, 22:11, Joel Perras [EMAIL PROTECTED] wrote: Take a look athttp://book.cakephp.org/view/66/models#deleting-data-516 . The 'dependent' parameter can also be set in the model association definition. Hope that's what you were looking for. -J. On Aug 19, 8:52 pm, Marcello [EMAIL PROTECTED] wrote: i got 2 tables linked by a HABTM relationship when ideletetable record 1 i want todeletethe relationship with table and the table 2 record as well but when ideletefrom table 2 i want to keep table 1 record is there any feature in cakephp forcascadingin habtm? --~--~-~--~~~---~--~~ 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: User Authentication Methods
I think the manual sums it up pretty nicely: Realize that ACL is not the same as authentication. ACL is what happens after a user has been authenticated. Although the two are usually used in concert, it's important to realize the difference between knowing who someone is (authentication) and knowing what they can do (ACL). On Aug 20, 5:56 pm, cem [EMAIL PROTECTED] wrote: Hi all ; I am a newbie who tries to understand the basics for now . The thing is suppose that I want to build a web app which has multiple user types . Like premium member regular member admin etc . Which isthe best method to authenticate users ? ACL or the Auth component . I am aboutto solve the logic of the ACL with database . But which one would you use ? --~--~-~--~~~---~--~~ 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: OrderedBehavior - Order your lists in a TreeBehavior like manner, but only for one level.
On Wed, Aug 20, 2008 at 4:03 PM, villas [EMAIL PROTECTED] wrote: @Tarique I am not arguing the value of bakery - you missed the point :D Well, in all fairness, I imagine Alkemann already knows about search engines but he would still like to publish his work on the Bakery. I believe that is the main point here. Ah! Yes, the altruistic desire share or the desire to earn the portfolio brownie points or whatever My contention is with the 'ad nauseum' whining which the audience of this list has to put up with because of these reasons. EOT for me Tarique -- = Cheesecake-Photoblog: http://cheesecake-photoblog.org PHP for E-Biz: http://sanisoft.com = --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Single session across multiple site error
I need single login functionality across multiple sites. For this I implemented the following code:- if(isset($this-params['pass']['0']) $this-params['pass'] ['0']=='sid'){ $db = ConnectionManager::getDataSource('default'); $sql = SELECT data FROM cake_sessions s WHERE s.id = '. $this-params[pass][1].' ; $res = $db-query($sql); $variables = array(); $a = preg_split( /(\w+)\|/, $res['0']['s']['data'], -1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); for( $i = 0; $i count( $a ); $i = $i+2 ) { $variables[$a[$i]] = unserialize( $a[$i +1] ); } $myData['User'] = $variables['User']; // if(session_id()!=$this-pharams[pass][1]){ // $this-Session-destroyOldSession($this-params[pass][1]); // $this-Session-write($myData); // } $this-DAuth-controller = $this; $this-DAuth-setUserData($myData['User']); } In this code I appended the last two lines so as to call setUserData() function of DAuth explicitly. And in setUserData() function in DAuth component class I added a die('***'); in the else part and then run the code and the code runs fine. Although the die('**'); was not called but it worked fine and user's data was not deleted from cake_sessions table. But If I remove the die statement then it deletes the records and log out from the site. --~--~-~--~~~---~--~~ 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: textbook find() query just doesn't work
Thanks for the response. I see that more clearly now. However, I still have the same problem even when doing a find() from the other model.. that is: GamePlayer belongsTo Game in my controller:... $cond = array(conditions=array(GamePlayer.user_id=1, Game.status=1)); $this-set('games', $this-GamePlayer-find('all',$cond)); Doesn't preform the join so i spits back at me SQL Error: 1054: Unknown column 'Game.status'... From what I understand so far this should work easily. There has to be something simple/stupid I'm missing. On Aug 20, 10:54 am, teknoid [EMAIL PROTECTED] wrote: The example in the manual is a little misleading. It assumes a belongsTo relationship between Post and Author (i.e. Post belongsTo Author). In that case a JOIN will be performed (remember, JOINs are only done for hasOne and belongsTo). I think the confusion is that it also mentions a hasMany relationship (i.e. Author hasMany Post), but in that case the JOIN is not forced. So, in other words, if you assumed that in the manual example there would be a call: $this-Post-find(... then a JOIN is performed and everything works as expected. If, however, it was $this-Author- find(... then one would likely to see an error similar to yours. P.S. I've submitted a correction to the manual. On Aug 19, 8:16 pm, Christian [EMAIL PROTECTED] wrote: In the manual I found an example of what I'm trying to do, except it doesn't work... - Let's say you had a hasMany/belongsTo relationship between Posts and Authors, which would result in a LEFT JOIN. Let's say you wanted to find all the posts that contained a certain keyword (“magic”) or were created in the past two weeks, but you want to restrict your search to posts written by Bob: code: array ( Author.name = Bob, or = array ( Post.title LIKE = %magic%, Post.created = date('Y-m-d', strtotime(-2 weeks)) ) ) - So you pass that as conditions to your find() call. I have a Game model and a GamePlayer model. Game hasMany GamePlayer. GamePlayer belongsTo Game. I want to find all games with inherent Game.status=1, and with an associated GamePlayer.user_id=1 $cond = array(conditions=array(Game.status=1)); $games = $this-Game-find('all',$cond)); -- This will return all the games with status=1, and right underneath the associated GamePlayers however, when i say.. $cond = array(conditions=array(Game.status=1,GamePlayer.user_id=1)); and repeat the find... it spits back at me Unknown column 'Game.status' in 'where clause' because it doesn't do a JOIN like the example from the cookbook says. I know this topic has come up on the google group elsewhere, but they either don't address this exact issue, or i try what is suggested and still no luck. I'd like to think this is a pretty basic and overused query for almost any application of databases. thanks, Christian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---