[5.0] chunk function improved

adding $columns param to chunk function is good for joined tables and defining columns if we want.
I have done it with a new pull request.