Dynamic Letter Filter for a Kohana Controller Object

Sarah Berg
December 26, 2012

Basically this is done with the “like” limiting SQL command. In Kohana, looking for users with names beginning with an “a” would be:


So we made a dynamic function in the controller that would retreive the users of a given letter.

$users = ORM::factory('company')->getUsers($letter);

This function can be placed in the the model of the controller, “$letter” can also be a substring:

public function getUsers($letter = '')
		$letter = $letter."%";
			$returnObj = ORM::factory('user')->find_all();
			$returnObj = ORM::factory('user')->where('name','LIKE',$letter)->find_all();
		return $returnObj;
Solutions Architecture

browse through our blog articles

Blog Archive