PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 21, 2022

[FIXED] How should data be formatted in CakePHP to save three levels of associations with saveAll()?

 October 21, 2022     cakephp, cakephp-1.3, has-many, php, save     No comments   

Issue

I'm trying to build an "Add an Event" page. You can add multiple "Schedules" - each of which will have calculations run on the date(s) / repeat options you set to create "Dates".

-Event hasMany Schedule
-Schedule hasMany Date
-Schedule belongsTo Event
-Date belongsTo Schedule

The question is - how does the data need to be formatted and/or how to the field names need to read in order to be able to saveAll() the data so Date(s) are also saved. I have it currently working so it saves the Event and the Schedule... but I can't get it to also save the Date(s).


Solution

Actually, since CakePHP 2.1, you can do it with saveAll(). Doesn't matter the deep level you have within your models. Here you can see the new features.

http://book.cakephp.org/2.0/en/appendices/new-features-in-cakephp-2-1.html#model-saveall-model-saveassociated-model-validateassociated



Answered By - Fay Perera
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,204,407

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing