Thursday, December 1, 2011

Filtering Component - Correct way of filtering results between two dates

I am quite new to CakePHp and the MVC way of thinking.

Up to know I was able to create resultsetfiltering by the use of the Filter
Component by Nik Chankov.

The way I am using it, is to call it in my Controller, saving the condition
statement and passing it to the Paginator.

Now, I have one column which holds a 'created_at' date and I want to give
the user a possibility to enter a start date and an end date and to pass it
to the filter component.

I tried creating two input text fields 'created_after' and 'created_before'
and to join these to an array[created_at][BETWEEN] in my controller since
the Filter Component handles 'BETWEEN' arrays.

Unfortunatelly, if I do not unset the original values I get a SQL Error
since the component will create a statement including 'created_after' and
created_before' which are not defined in my database. But if I do unset
created_before and _after, they won't be saved to the session ( this is
handled by filtering component aswell ) and I can not use Paginator anymore.

What would be the correct way of doing this? Please give me advise how and
into which direction I should proceed to solve this issue... I am kind of
stuck and I would love to somehow add this to the Filtering and not to
create a hack in my Controller...

thanks!

--
View this message in context: http://cakephp.1045679.n5.nabble.com/Filtering-Component-Correct-way-of-filtering-results-between-two-dates-tp5039403p5039403.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: