Sql optimise conflicts resolve branch

PR#9,PR#18 and PR#32 changes included in one PR
the for each should be changed like this or a more elegant way 
	foreach ($fieldsList as $key => $value)
		{
			if ($fieldsList[$key][0] == 'AS category_route')
			{
				$catPathField = 'c.path AS category_route';
			//	$parentPathField = 'parent.path AS parent_route';
			}
			if ($fieldsList[$key][0] == 'AS parent_route')
			{
		//		$catPathField = 'c.path AS category_route';
		  		$parentPathField = 'parent.path AS parent_route';
			}
		}