Re: Model chaining for a find statement not returning expected results

2014-09-12 Thread Stephen S
No problem Paul The dogmatic69 website seems like a good resource, plural tables, singular foreign keys (underscored followed by _id) and usually a good idea to add created DATETIME and modified DATETIME to each table (with the exception of hasAndBelongsToMany etc) Hopefully this will work out fo

Re: Model chaining for a find statement not returning expected results

2014-09-12 Thread Paul Drage
Thanks Stephen I did a cake bake all (auto) which generated all the models- in hindsight perhaps manually coding them would have been an advantage? I used dogmatic69(.com) yesterday and it told me there was about 3 tables which were named incorrectly: it would of been nice for cake bake to te

Re: Model chaining for a find statement not returning expected results

2014-09-11 Thread Stephen S
I think it's also worth mentioning that you don't need to define all the parameters of an association if you're not overwriting the default values, this can be a good way to test if you've set up your associations correctly. public $belongsTo = array( 'DeviceType' ); I will also note that in

Re: Model chaining for a find statement not returning expected results

2014-09-11 Thread Stephen S
Hi Paul I notice you've got both DeviceRepairs and DeviceRepair within your associations, this is likely your issue. It's convention to have a singular model name i.e. *DeviceRepair, RepairType*, a plural controller name i.e. *DeviceRepairsController, RepairTypesController* and a plural table nam

Re: Model chaining for a find statement not returning expected results

2014-09-11 Thread Paul Drage
Cheers for that Mike, I tried containing and ran into lots of different issues, I then spent about half an hour writing a REALLY UGLY javascript client side hack to do my lookup for me (against a different set of results), it was fast becoming a farce (see what i did there?) Would you be happy

Re: Model chaining for a find statement not returning expected results

2014-09-11 Thread Mike Karthauser
hi paul if you are using recursive =1 in you queries you won't get all the info you need. I suggest you look at containable behaviour. ] http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html BTW Its makes no odds which controller calls the model function. On 11 Sep 2014, at

Re: Model chaining for a find statement not returning expected results

2014-09-11 Thread Paul Drage
Should i just move everything to a different controller? surely there must be a way to do the association i need right in/before the query?? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subsc

Re: Model chaining for a find statement not returning expected results

2014-09-09 Thread Paul Drage
Any thoughts are welcome at all - I've managed to run the chained query in a different controller so I'm now sure it's my has many/belongs to rules - But after trying some (even more) ideas with the relationships i'm still getting the error relating to a non object when i try it in the controlle

Model chaining for a find statement not returning expected results

2014-09-08 Thread Paul Drage
Hi Guys, I've been trying to get this query going for a couple of days - I wrote some really hacky (non cakey php) code to lookup a 'name' field given the 'id' field that I *am* getting out of the query - it sort of worked but it was a real mess. I know that this can be done, and it can be don