문제

just a quick question. I'm developping in cakePHP

I'd like to add a reference number to every entry in my Model, and for that i'd like a function, that will be executed in the Model's beforeSave() that will count the number of entries already created this month, and my ref number will then be YYYMMXXX, with XXX the number of this entry since day one of the month.

Should i place this counting function in the Controller or the Model ? I have a doubt here..

Thanks for the advice !

도움이 되었습니까?

해결책

It will be better to place the functon in your model because logical part of coding is done in the model.Also it will provide reusability of code.Since controller is not used for writing logic you can use model for that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top