Welcome to Kodok Marton's homepage

Professional work from professionals!

  • Increase font size
  • Default font size
  • Decrease font size
Home Programming Web Programming
Web Programming

Remember filters gridview Yii extension (updated June 3, 2011)

This extensions helps you to remembered/store filter values of GridViews between navigation, filters will stick.

The ERememberFiltersBehavior extension adds up some functionality to the default possibilites of CActiveRecord/Model implementation.

It will detect the search scenario and it will save the filters from the GridView. This comes handy when you need to remember them between navigation during page changes. For lot of navigation and heavy filtering, this functionality can be activated by just a couple of lines.


Resources for faster programming - time-honored methods

A gyorsabb programozast elosegito eroforrasok


How to count all NULL values in a table?

The other day I came across with a situation when a guy asked about how can he count all NULL values in a table, not only on a specific column.

He wanted to use the value for their contacts database report. Where all the columns for a contact is preferred but not mandatory, he just want to generate a quick report on the completion percentage of contact information in the entire table. He wanted to count from all the columns and not from one.


Getting a list of days from SQL date range (the most surreal query ever seen)

I asked a few days ago on a forum for help, to run a TSQL query like

select ... as days where `date` is between '2010-01-20' and '2010-01-24'

And return data like:

I ended up with the most surreal query ever seen in my life:

How to properly get user's birthday from database (solution for 29th February)

Today, I came across a problem, where I had to get from database all users that celebrate today. This is not as easy as it sounds, as there are leap years, and users having their birthday on 29th February will be returned only in 4 years. It's better return them on 1st March if the 29th February doesn't exists in that year. Actually, if you need to be serious about this, you have to take into account, that every 100 years, there's no leap year, but every 400 there is. 

Here is an answer that property takes into account leap-years and will always give you the users whose birthday is on the 29th of February at the same time as those on the 1st of March.

(FROM_UNIXTIME(birthDate),'%m-%d') = DATE_FORMAT(NOW(),'%m-%d')
(NOW(),'%Y') % 4 <> 0
(NOW(),'%Y') % 100 = 0
                        AND DATE_FORMAT
(NOW(),'%Y') % 400 <> 0
            AND DATE_FORMAT
(NOW(),'%m-%d') = '03-01'
            AND DATE_FORMAT
(FROM_UNIXTIME(birthDate),'%m-%d') = '02-29'



Page 2 of 3