# Fetching specific records in a RESTful application

Basically what I'm trying to achieve here is I need to fetch a set of images based on the selected folder. Is this a correct way to do it?

I'm using ZF 2.5, and have the following function in my RESTful Images controller:

public function getList()
{
$folder_id =$this->params()->fromQuery('folder_id', 0);
$images =$this->ImagesTable->getImages($folder_id); // Code for returning response }  This is what my table function looks like: public function getImages($folder_id)
{
$select =$this->tableGateway->getSql()->select();

if(!empty($folder_id)) {$select->where(array('folder_id' => $folder_id)); }$resultSet = $this->tableGateway->selectWith($select);

return $resultSet->count() > 0 ?$resultSet : null;
}