Thanks for the "step in the right direction". I might be back after
the suggested reading and searching.

On Jan 6, 4:02 pm, Webweave <[email protected]> wrote:
> You can definitely do queries in the validation, and it sounds like
> you're on the right track.
>
> Readhttp://book.cakephp.org/view/152/Custom-Validation-Methodsand it
> will give you some ideas.
>
> I think your other question is how to write a query that will tell you
> if the range overlaps an existing one, so you'd really just need to
> look for:
>
> ((new_start_time < existing_end_time) and (new_end_time >
> existing_start_time))
> or
> ((new_end_time < existing_end_time) and (new_start_time >
> existing_start_time))
>
> You should be able to find a nice query by doing a search for date
> range overlap on google.
>
> On Jan 6, 12:24 pm, fly2279 <[email protected]> wrote:
>
> > I am new to cake and was wondering if someone could help point me in
> > the right direction. I am trying to create something similar to a
> > weekly planner with additional rules. Each user has many "time blocks"
> > that they can enter (something like a punch clock where you enter a
> > start and end time of your block). Depending on what the user selects,
> > each time block has different validation rules that apply to that
> > block. For instance a new time block is added that starts at 5:00 a.m.
> > and stops at 5:00 p.m. The user has selected a "10 hour rule" from the
> > input form. What I need is to be able to validate that there is 10
> > hours before this "time block" that doesn't have another time block in
> > it. I also need to check any existing time blocks that might have
> > different rules attached. For example an existing block may end 11
> > hours before the one being validated and added but the previous block
> > may have a rule that does not allow anything 12 hours after. This
> > would invalidate the existing block and not allow the current one to
> > be saved.
>
> > I think this isn't really "business logic" that would go into a
> > controller but rather data validation that should go into the model. I
> > just don't know how to construct the parameters, the mysql query part
> > nor how to set it up in the model. Do I create a function that goes
> > into the $validate array? How would the mysql query be setup there?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to