# |
Jan 30th 2014, 20:29 |
chris______ |
also my join table would be named orders_items, order_items? |
# |
Jan 30th 2014, 20:28 |
BackEndCoder |
please keep me up to date |
# |
Jan 30th 2014, 20:28 |
chris______ |
thank you, I'll do it right away and let you know |
# |
Jan 30th 2014, 20:28 |
BackEndCoder |
yes yes |
# |
Jan 30th 2014, 20:28 |
chris______ |
I see |
# |
Jan 30th 2014, 20:28 |
BackEndCoder |
but the saveAll needs to look like $this->Order->OrderItems->saveAll($data['OrderItems']); |
# |
Jan 30th 2014, 20:28 |
chris______ |
So the first save() would be to save the new Order and get its ID, and then saveAll() to save the associations? |
# |
Jan 30th 2014, 20:27 |
BackEndCoder |
you can do it from your Orders controller if you wish |
# |
Jan 30th 2014, 20:27 |
BackEndCoder |
and then saveAll after that |
# |
Jan 30th 2014, 20:27 |
BackEndCoder |
you want to do the orignal save() to save the order number |
# |
Jan 30th 2014, 20:26 |
chris______ |
Can I do the save operation from the OrdersController, or should I do it on the OrderItems Controller? |
# |
Jan 30th 2014, 20:26 |
chris______ |
I see |
# |
Jan 30th 2014, 20:26 |
BackEndCoder |
so each numerial array, is a row. you don't want to model define it again |
# |
Jan 30th 2014, 20:25 |
BackEndCoder |
chris______, ok, so you need this array set. http://bin.cakephp.org/view/338066217 see CustomerPrice. make your array look like this. and your saveAll will work |
# |
Jan 30th 2014, 20:24 |
Nick____ |
does the condition filter down? so if i filter pages but then this then joins and gets sub pages |
# |
Jan 30th 2014, 20:24 |
chris______ |
BackEndCoder: sorry I had to go out for a second, im back now. here is it http://bin.cakephp.org/view/1274421597 |
# |
Jan 30th 2014, 20:24 |
the-neon |
perhaps 'conditions' would be the key you need |
# |
Jan 30th 2014, 20:24 |
the-neon |
if you mean retrieve on the relationship |
# |
Jan 30th 2014, 20:24 |
the-neon |
output on view? |
# |
Jan 30th 2014, 20:24 |
the-neon |
retrieve? |
# |
Jan 30th 2014, 20:23 |
the-neon |
when you say show... you mean? |
# |
Jan 30th 2014, 20:23 |
Nick____ |
how hard is it to only show child pages based on a variable too? so only show child pages where active=1 |
# |
Jan 30th 2014, 20:23 |
the-neon |
Nick___ yup! you got it |
# |
Jan 30th 2014, 20:23 |
the-neon |
Nick___ careful on your declaration tho, I had a weird error because I was careless |
# |
Jan 30th 2014, 20:22 |
Nick____ |
https://gist.github.com/anonymous/6ad1338cf012cc56f51d |
# |
Jan 30th 2014, 20:22 |
kerin |
Just felt inelegant :/ |
# |
Jan 30th 2014, 20:22 |
Nick____ |
I think I found it :) |
# |
Jan 30th 2014, 20:22 |
the-neon |
kerin, sweet |
# |
Jan 30th 2014, 20:22 |
kerin |
BackEndCoder, the-neon, no longer an issue. Wrote a loop to make pretty arrays, done and done |
# |
Jan 30th 2014, 20:22 |
the-neon |
the book has an example on relationships between the same model |
# |
Jan 30th 2014, 20:22 |
the-neon |
Nick____, yes |
# |
Jan 30th 2014, 20:21 |
Nick____ |
Is it possible to do a join within the same model? for example a page may have a parent_id column, so I want to get ALL pages where parent ID is null (all parents) and then within the array of the page get all child pages |
# |
Jan 30th 2014, 20:20 |
kerin |
I misspoke earlier |
# |
Jan 30th 2014, 20:20 |
kerin |
the-neon, fetchAll |
# |
Jan 30th 2014, 20:20 |
chris______ |
Here it is the debugged $this->request->data and $relationshipData http://bin.cakephp.org/view/1274421597 |
# |
Jan 30th 2014, 20:20 |
the-neon |
is that array through Containable or a chain find? |
# |
Jan 30th 2014, 20:19 |
BackEndCoder |
why its giving you 0 arrays inside i don't know howeverf |
# |
Jan 30th 2014, 20:19 |
BackEndCoder |
you will have to malipulate it before you push it to the view |
# |
Jan 30th 2014, 20:19 |
the-neon |
yeah |
# |
Jan 30th 2014, 20:19 |
BackEndCoder |
as its clearly not |
# |
Jan 30th 2014, 20:19 |
BackEndCoder |
it will only come out how you would prefer if its all from the same table |