I am in the position where I need to remove records form a dataprovider. Long story shot, I have encrypted data in my db that is decrypted using the afterfind
method. I need to ensure the decrypted string is 20 characters long and show the result in a cgrid view.
I have tried the visible option
, but this hides the data on a per column basis. I have tried the rowCssClassExpression
which successfully hides the rows on the screen using display:none
, however, it still shows 1 of 1200 results even though only 10 match and also page 1 has one result, page 2 no results, page 3 2 results etc.
Currently I am able to get this working by doing a cdbcommand
queryAll
and then looping through and calling the object like so:
foreach($data as $key=>$d)
{
$lengthCheck = Data::model()->findByPk($d['id'])->checkLength;
if($lengthCheck !== true)
{
unset($data[$key]);
}
etc.
I can then use the resulting array in an arrayDataProvider
, so effectively I can get the information I need using this methods, however, It is taking over 2 seconds per record, so effectively this would be over 3 minutes for 100 records.
Does anyone have an idea of how I could do this in a smarter/faster way?