Which parts of the framework can be used outside the framework?
I've noticed that stuff like the Event library have their own readme's does that mean that the library can be used outside the framework, like a component? I'm making a presentation and I would like a list of all the parts of the framework which can be used outside the framework as a bonus point for Cake. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Post idea: Long term, large scales projects with CakePHP
The reason I included the bit about the 'core developer' was because they would have the best understanding of how the core components work and which software design principles they encompass. I do agree that we can all do something to help market the framework, but marketing needs to come from an 'official' channel. Sure it could be a book page created collaboratively by the community, which I think would help rather than a blog post. Hence why I decided to post on groups rather than just try and write up a post myself. I'd certainly be happy to get something started. Perhaps I should start a repo on GH with a markdown document? I've been invited to speak about CakePHP at a local usergroup so this would be ideal preparation. I'm not too sure on the topics which should be covered though, short of the software design principles. An example from the last talk was the separation of concerns and that models shouldn't know how to save their data, and model data should be just data. Perhaps some of the topics could just revolve around user-contributed tips and tricks? Such as good caching, routing tweaks and any other tweaks. On 15 August 2014 10:31, José Lorenzo jose@gmail.com wrote: I really like the idea David, CakePHP definitely needs more and better marketing. What I disagree with is that only a core developer or something with a lot of experience can write such articles or help promoting the framework, anyone could start adding their experiences with CakePHP, even just to say It made my day a bit easier. What would you propose to encourage more people contributing that kind of feedback? Would you be willing to write an article we can expose as a case study? On Thursday, August 14, 2014 4:58:55 PM UTC+2, David Yell wrote: *TL;DR*, Tell people why and how a RAD framework can compete with the likes of Symfony for larger projects which have a long lifetime. As we all know CakePHP get's a pretty bad rep in the PHP community and no more so than from the Symfony corner. They love to belittle the framework and regurgitate Uncle Bob. It would be nice to have a bit of a slap-down post about using a RAD framework can be for more than just prototyping. It would be great for someone with good knowledge of the core to detail some of the software design principles being used in the framework and how you can build large scale commercial and stable applications using CakePHP. So often people look down on CakePHP because they see it as being magic, tightly coupled or slow. Yeah, we've all heard them spouting this garbage. So why not address it? I think a post or even a book page which extols the virtues of the framework would be beneficial. Something which advertises the framework, why it's cool, what it does which is cool. I know there are some large scale sites out there using the framework. I know I've built a few which *I'd consider* reasonably high traffic (eg, 80k unique visitors a month). So it can be done. I also know that there are plugins, tips, hints and optimisations out there which people have done to help their app. Streamlining the framework by removing all the default routes for example. Making better use of caching. Whatever it might be I would really like to see some Laravel style marketing happening for CakePHP because it is a good framework. I'd welcome other peoples thoughts and suggestions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to a topic in the Google Groups CakePHP group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/XtbhyWkl-l8/unsubscribe. To unsubscribe from this group and all its topics, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Post idea: Long term, large scales projects with CakePHP
So I have created the repo and put some placeholder files in there, with a bit of copy. If I need to write about the software patterns I will need to learn the core and learn about software patterns, so that one might take a while. I'll work on the tips and tricks mostly, as long as I can remember all the clever stuff I've been told. I would welcome contributions, so please feel free to fork and PR your thoughts, ideas and such. Hopefully once it's up to par we can look at incorporating it into the book, or into a page 'About the framework' or similar on the website -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Post idea: Long term, large scales projects with CakePHP
It would have been super helpful to include the link to the repo, d'oh https://github.com/davidyell/BakeYourDreams -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Post idea: Long term, large scales projects with CakePHP
*TL;DR*, Tell people why and how a RAD framework can compete with the likes of Symfony for larger projects which have a long lifetime. As we all know CakePHP get's a pretty bad rep in the PHP community and no more so than from the Symfony corner. They love to belittle the framework and regurgitate Uncle Bob. It would be nice to have a bit of a slap-down post about using a RAD framework can be for more than just prototyping. It would be great for someone with good knowledge of the core to detail some of the software design principles being used in the framework and how you can build large scale commercial and stable applications using CakePHP. So often people look down on CakePHP because they see it as being magic, tightly coupled or slow. Yeah, we've all heard them spouting this garbage. So why not address it? I think a post or even a book page which extols the virtues of the framework would be beneficial. Something which advertises the framework, why it's cool, what it does which is cool. I know there are some large scale sites out there using the framework. I know I've built a few which *I'd consider* reasonably high traffic (eg, 80k unique visitors a month). So it can be done. I also know that there are plugins, tips, hints and optimisations out there which people have done to help their app. Streamlining the framework by removing all the default routes for example. Making better use of caching. Whatever it might be I would really like to see some Laravel style marketing happening for CakePHP because it is a good framework. I'd welcome other peoples thoughts and suggestions. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Selecting specific data from the database through multiple relations
*Synopsis* Trying to select data from multiple related models explicitly is hard in the framework due to it's focus on always providing a left join. Even with Containable and Linkable it's not always possible, without a manual query, to select records where their related record has a condition. Such as selecting all Posts where a Tag is authored by User x. It seems odd to me that the framework should return empty related model records or, if using linkable not return all the related records. I am starting this thread to discuss solutions, tips, tricks and techniques for achieving this functionality as I do not feel that either Containable or Linkable accurately cover this use-case. It may well be that case that some more guidance is needed in the documentation for this specific type of query. *The problem* You would like to select from primary model but only if related models conditions are met. The primary model should only be included in the result set if the related model conditions are met. With a single related model this is quite easy using Linkable. However when you start trying to achieve this across HABTM, hasManyThrough or two or three nested models the problem grows in complexity. A few examples, might make things clearer. *Hotel hasMany HotelFeature belongsTo Feature* You need to select hotels which have n number of specific features. The hotel must have all of the features listed to be included in the dataset. *Post hasMany PostsTag belongsTo Tag belongsTo User* You need to find all the posts which have tags created by a certain user. *Hotel belongsTo City belongsTo Province belongsTo Country* You need to select all the cities in a country where there is a hotel. I'm sure there are some other use-cases, but these are the ones of the top of my head. As you can see it's usually selecting a primary record where a related record matches a certain condition, but where the related record is a multiple. *Possible solutions* This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome ORM. The only real thing that I can think of is either more enhancements to Containable or Linkable really. However I am not sure how to approach such a problem. I was told once in an interview that any more than five joins will impact performance in MySQL (could be fiction), so obviously there is a performance concern with highly normalised databases. Concerns which are ignored by Containable with it's multiple queries across many models - a solution which I think was devised to solve this problem. *Discussion* The idea of the thread was to discuss potential solutions really. I wanted to air my thoughts on a problem which I have hit many times with my current project and have had to battle against. Usually using manual joins, but in most cases I end up using Containable and filtering the data in the front-end `foreach()` which isn't elegant, clever or clean. I'm sure this kind of issue will have been addressed with the new ORM in 3.x, but I need to find a decent solution to this problem which will be flexible enough to be beneficial to lots of different projects, and to other Cake users. We are all taught to normalise, and it makes sense to do so, but this issue keeps nagging at me and I'm finding it frustrating. I don't feel that the framework is helping me solve such a problem. If you read to here, thanks, have a biscuit and share your thoughts. How do you get around this issue? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Selecting specific data from the database through multiple relations
I wasn't aware that Linkable took different types of joins. On Tuesday, 22 July 2014 11:50:38 UTC+1, José Lorenzo wrote: Not sure why linkable is not working for you. Did you make sure to set 'type' = 'INNER' in the linkable definition for that model? That will filter records from the parent model according to the conditions in the association. On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote: *Synopsis* Trying to select data from multiple related models explicitly is hard in the framework due to it's focus on always providing a left join. Even with Containable and Linkable it's not always possible, without a manual query, to select records where their related record has a condition. Such as selecting all Posts where a Tag is authored by User x. It seems odd to me that the framework should return empty related model records or, if using linkable not return all the related records. I am starting this thread to discuss solutions, tips, tricks and techniques for achieving this functionality as I do not feel that either Containable or Linkable accurately cover this use-case. It may well be that case that some more guidance is needed in the documentation for this specific type of query. *The problem* You would like to select from primary model but only if related models conditions are met. The primary model should only be included in the result set if the related model conditions are met. With a single related model this is quite easy using Linkable. However when you start trying to achieve this across HABTM, hasManyThrough or two or three nested models the problem grows in complexity. A few examples, might make things clearer. *Hotel hasMany HotelFeature belongsTo Feature* You need to select hotels which have n number of specific features. The hotel must have all of the features listed to be included in the dataset. *Post hasMany PostsTag belongsTo Tag belongsTo User* You need to find all the posts which have tags created by a certain user. *Hotel belongsTo City belongsTo Province belongsTo Country* You need to select all the cities in a country where there is a hotel. I'm sure there are some other use-cases, but these are the ones of the top of my head. As you can see it's usually selecting a primary record where a related record matches a certain condition, but where the related record is a multiple. *Possible solutions* This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome ORM. The only real thing that I can think of is either more enhancements to Containable or Linkable really. However I am not sure how to approach such a problem. I was told once in an interview that any more than five joins will impact performance in MySQL (could be fiction), so obviously there is a performance concern with highly normalised databases. Concerns which are ignored by Containable with it's multiple queries across many models - a solution which I think was devised to solve this problem. *Discussion* The idea of the thread was to discuss potential solutions really. I wanted to air my thoughts on a problem which I have hit many times with my current project and have had to battle against. Usually using manual joins, but in most cases I end up using Containable and filtering the data in the front-end `foreach()` which isn't elegant, clever or clean. I'm sure this kind of issue will have been addressed with the new ORM in 3.x, but I need to find a decent solution to this problem which will be flexible enough to be beneficial to lots of different projects, and to other Cake users. We are all taught to normalise, and it makes sense to do so, but this issue keeps nagging at me and I'm finding it frustrating. I don't feel that the framework is helping me solve such a problem. If you read to here, thanks, have a biscuit and share your thoughts. How do you get around this issue? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Selecting specific data from the database through multiple relations
I have managed to solve some issues, like counting hotels using things similar to the following model method. /** * Find a list of all the regions and how many hotels are in each region * * @return array */ public function regionWithHotelCount() { return $this-find('all', [ 'link' = [ 'CountriesRegion' = [ 'fields' = ['id', 'country_id', 'region_id'], 'Country' = [ 'fields' = ['id'], 'State' = [ 'fields' = ['id'], 'City' = [ 'fields' = ['id'], 'Hotel' = [ 'fields' = ['id'], ] ] ] ] ] ], 'fields' = ['Region.slug', 'CountriesRegion.region_id', 'Region.name', 'COUNT(Hotel.id) as NumHotels'], 'group' = 'CountriesRegion.region_id' ]); } On Tuesday, 22 July 2014 11:57:59 UTC+1, David Yell wrote: I wasn't aware that Linkable took different types of joins. On Tuesday, 22 July 2014 11:50:38 UTC+1, José Lorenzo wrote: Not sure why linkable is not working for you. Did you make sure to set 'type' = 'INNER' in the linkable definition for that model? That will filter records from the parent model according to the conditions in the association. On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote: *Synopsis* Trying to select data from multiple related models explicitly is hard in the framework due to it's focus on always providing a left join. Even with Containable and Linkable it's not always possible, without a manual query, to select records where their related record has a condition. Such as selecting all Posts where a Tag is authored by User x. It seems odd to me that the framework should return empty related model records or, if using linkable not return all the related records. I am starting this thread to discuss solutions, tips, tricks and techniques for achieving this functionality as I do not feel that either Containable or Linkable accurately cover this use-case. It may well be that case that some more guidance is needed in the documentation for this specific type of query. *The problem* You would like to select from primary model but only if related models conditions are met. The primary model should only be included in the result set if the related model conditions are met. With a single related model this is quite easy using Linkable. However when you start trying to achieve this across HABTM, hasManyThrough or two or three nested models the problem grows in complexity. A few examples, might make things clearer. *Hotel hasMany HotelFeature belongsTo Feature* You need to select hotels which have n number of specific features. The hotel must have all of the features listed to be included in the dataset. *Post hasMany PostsTag belongsTo Tag belongsTo User* You need to find all the posts which have tags created by a certain user. *Hotel belongsTo City belongsTo Province belongsTo Country* You need to select all the cities in a country where there is a hotel. I'm sure there are some other use-cases, but these are the ones of the top of my head. As you can see it's usually selecting a primary record where a related record matches a certain condition, but where the related record is a multiple. *Possible solutions* This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome ORM. The only real thing that I can think of is either more enhancements to Containable or Linkable really. However I am not sure how to approach such a problem. I was told once in an interview that any more than five joins will impact performance in MySQL (could be fiction), so obviously there is a performance concern with highly normalised databases. Concerns which are ignored by Containable with it's multiple queries across many models - a solution which I think was devised to solve this problem. *Discussion* The idea of the thread was to discuss potential solutions really. I wanted to air my thoughts on a problem which I have hit many times with my current project and have had to battle against. Usually using manual joins, but in most cases I end up using Containable and filtering the data in the front-end `foreach()` which isn't elegant, clever or clean. I'm sure this kind of issue will have been addressed with the new ORM in 3.x, but I need to find a decent solution to this problem which will be flexible enough to be beneficial to lots of different projects, and to other Cake users. We are all taught to normalise, and it makes sense to do so, but this issue keeps nagging at me and I'm finding it frustrating. I don't feel that the framework is helping me solve such a problem. If you read to here, thanks, have a biscuit and share your thoughts. How do you get around this issue? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php
Re: Selecting specific data from the database through multiple relations
Managed to solve it with something like this in some cases. /** * Find a list of all the regions and how many hotels are in each region * * @return array */ public function regionWithHotelCount() { return $this-find('all', [ 'link' = [ 'CountriesRegion' = [ 'fields' = ['id', 'country_id', 'region_id'], 'Country' = [ 'fields' = ['id'], 'State' = [ 'fields' = ['id'], 'City' = [ 'fields' = ['id'], 'Hotel' = [ 'fields' = ['id'], ] ] ] ] ] ], 'fields' = ['Region.slug', 'CountriesRegion.region_id', 'Region.name', 'COUNT(Hotel.id) as NumHotels'], 'group' = 'CountriesRegion.region_id' ]); } On Tuesday, 22 July 2014 11:57:59 UTC+1, David Yell wrote: I wasn't aware that Linkable took different types of joins. On Tuesday, 22 July 2014 11:50:38 UTC+1, José Lorenzo wrote: Not sure why linkable is not working for you. Did you make sure to set 'type' = 'INNER' in the linkable definition for that model? That will filter records from the parent model according to the conditions in the association. On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote: *Synopsis* Trying to select data from multiple related models explicitly is hard in the framework due to it's focus on always providing a left join. Even with Containable and Linkable it's not always possible, without a manual query, to select records where their related record has a condition. Such as selecting all Posts where a Tag is authored by User x. It seems odd to me that the framework should return empty related model records or, if using linkable not return all the related records. I am starting this thread to discuss solutions, tips, tricks and techniques for achieving this functionality as I do not feel that either Containable or Linkable accurately cover this use-case. It may well be that case that some more guidance is needed in the documentation for this specific type of query. *The problem* You would like to select from primary model but only if related models conditions are met. The primary model should only be included in the result set if the related model conditions are met. With a single related model this is quite easy using Linkable. However when you start trying to achieve this across HABTM, hasManyThrough or two or three nested models the problem grows in complexity. A few examples, might make things clearer. *Hotel hasMany HotelFeature belongsTo Feature* You need to select hotels which have n number of specific features. The hotel must have all of the features listed to be included in the dataset. *Post hasMany PostsTag belongsTo Tag belongsTo User* You need to find all the posts which have tags created by a certain user. *Hotel belongsTo City belongsTo Province belongsTo Country* You need to select all the cities in a country where there is a hotel. I'm sure there are some other use-cases, but these are the ones of the top of my head. As you can see it's usually selecting a primary record where a related record matches a certain condition, but where the related record is a multiple. *Possible solutions* This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome ORM. The only real thing that I can think of is either more enhancements to Containable or Linkable really. However I am not sure how to approach such a problem. I was told once in an interview that any more than five joins will impact performance in MySQL (could be fiction), so obviously there is a performance concern with highly normalised databases. Concerns which are ignored by Containable with it's multiple queries across many models - a solution which I think was devised to solve this problem. *Discussion* The idea of the thread was to discuss potential solutions really. I wanted to air my thoughts on a problem which I have hit many times with my current project and have had to battle against. Usually using manual joins, but in most cases I end up using Containable and filtering the data in the front-end `foreach()` which isn't elegant, clever or clean. I'm sure this kind of issue will have been addressed with the new ORM in 3.x, but I need to find a decent solution to this problem which will be flexible enough to be beneficial to lots of different projects, and to other Cake users. We are all taught to normalise, and it makes sense to do so, but this issue keeps nagging at me and I'm finding it frustrating. I don't feel that the framework is helping me solve such a problem. If you read to here, thanks, have a biscuit and share your thoughts. How do you get around this issue? -- Like Us
Re: How could I change Paginator-numbers() render from span to the select
I would tackle it by extending the Paginator class to include a customNumbers() style function which would take this into account. As far as I know this isn't available with the current paginator class, although I could be wrong. A quick check on http://api.cakephp.org/class_paginator_helper.html#bd8d81f8fffdce0f12c61aa453073d99 would lead me to try wrapping an option/option into the before and after options to see what the output would be like, this might work. Good luck, Dave On Oct 8, 11:02 am, Elmaho [EMAIL PROTECTED] wrote: In this url whose controller will receive page:2 parameter /site/contrs/action/page:2 please if you have any suggestion, solution replay me thanks On 8 oct, 09:46, Elmaho [EMAIL PROTECTED] wrote: hi, the render of the numbers() function in the paginator helper is a list of span tags, have you any idea to change this one into a select tag. i can't figure it ?? thank you readers. --~--~-~--~~~---~--~~ 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: Filter a paginated dataset using a related field through a habtm relationship (1.2)
I finally managed to get this working using a model bind. It's a bit messy and doesn't really make a whole lot of sense to me just yet. I was basically changing things and looking at the sql. For anyone looking for this type of functionality, I achieved it using this in my controller. ?php function index() { $this-checkRole(array(1,3)); $this-Link-recursive = 1; $this-Link-bindModel( array('belongsTo' = array( 'CategoriesLink' = array( 'className' = 'CategoriesLink', 'foreignKey' = 'id', ) )), array('belongsTo' = array( 'Category' = array( 'className' = 'Category', 'foreignKey' = 'categories_link_id', ) )) ); if(isset($this-params['named']['category'])){ $data = $this-paginate('Link', array('CategoriesLink.category_id'= $this-params['named']['category'])); } else { $data = $this-paginate('Link', array('Link.status_id'='1')); } die(pr($data)); $this-set('links', $data_mod); $categories = $this-Link-Category-find('list'); $this-set(compact('categories')); } ? On Aug 20, 12:34 pm, David Yell [EMAIL PROTECTED] wrote: 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 -~--~~~~--~~--~--~---
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 -~--~~~~--~~--~--~---
Selective field model validation
Hi, I've been doing some work with my users model and I got to a stage where I was creating a method to change a users password to avoid the default edit screen from having a populated password and such. Either way I ended up with a change_password method and view, this works great. On this page I have two password fields which are checked using a custom match rule in my model btw. Then if they pass validation I copy one into the password field and save it. The validation is called using $this-User-validates() in the controller. But I was trying to validate the password and my model was throwing all kinds of strange errors. When I finally dropped in a die(pr($this-User- invalidFields())); into my controller it was showing that all the other fields, which were marked as required were also being validated. I got around it by adding the fields as hidden to the form and submitting it. The main question is, is there a way to pass any field list into validates or create a validateFields() which takes an array of fields to validate? Is this possible? My colleague tells me that I should really be creating a passwords model and such and then relating it to my User but this seems a little overkill. In a similar circumstance which I just arrived at again, I am forwarding a job to a friend via email and I would like to validate the email field against the model before sending the email. Again I can't validate just this one field without validating the whole model. Yet again, should I be creating a ForwardtoFriend model with no table and it's own controller to do this and then associate it with the Vacancy? It seems to me that it might be a bit of a hacky shortcut to be able to specify which model fields you want to validate, but one that would be super handy, or am I missing the point here? (which is entirely possible ;p) Ta, Dave --~--~-~--~~~---~--~~ 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: Selective field model validation
This was solved in #cakephp By using $this-Model-validates($this-data['Model']['field'] So big thanks to penfold_99 for sorting this for me, thanks! On Aug 18, 3:26 pm, David Yell [EMAIL PROTECTED] wrote: Hi, I've been doing some work with my users model and I got to a stage where I was creating a method to change a users password to avoid the default edit screen from having a populated password and such. Either way I ended up with a change_password method and view, this works great. On this page I have two password fields which are checked using a custom match rule in my model btw. Then if they pass validation I copy one into the password field and save it. The validation is called using $this-User-validates() in the controller. But I was trying to validate the password and my model was throwing all kinds of strange errors. When I finally dropped in a die(pr($this-User-invalidFields())); into my controller it was showing that all the other fields, which were marked as required were also being validated. I got around it by adding the fields as hidden to the form and submitting it. The main question is, is there a way to pass any field list into validates or create a validateFields() which takes an array of fields to validate? Is this possible? My colleague tells me that I should really be creating a passwords model and such and then relating it to my User but this seems a little overkill. In a similar circumstance which I just arrived at again, I am forwarding a job to a friend via email and I would like to validate the email field against the model before sending the email. Again I can't validate just this one field without validating the whole model. Yet again, should I be creating a ForwardtoFriend model with no table and it's own controller to do this and then associate it with the Vacancy? It seems to me that it might be a bit of a hacky shortcut to be able to specify which model fields you want to validate, but one that would be super handy, or am I missing the point here? (which is entirely possible ;p) Ta, Dave --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---