public static function _getGrid ($params = array (), $relations = array (), &$db = FALSE)
	{
		
		// If no limit has been set

		if (!$params || !isset ($params['limit']))
		{

			// Set default query limit
			
			$params['limit'] = array (0, 50);

		}
		
		// Get data
		
		if ($relations)
		{
			
			$objs	= static::_getObjects ($params, $db);
			$data	= array ();
			
			foreach ($objs as $obj)
			{
				
				$attributes	= is_array ($params['select'])? $params['select'] : explode (',', $params['select']);
				
				foreach ($attributes as &$val)
				{
					$val = trim ($val);
				}
				
				$data[] = $obj->toArray ($attributes, $relations);
				
			}
			
		}
		else
		{
			$data	= static::_getValues ($params, $db);
		}
		
		// Get count
		
		$count	= self::_count ($params, $db);

		// If there was a problem return FALSE

		if ($count === FALSE || $data === FALSE)
		{
			return FALSE;
		}
		
		// Add class (for API XML response)
		
		$class	= self::_getClass ();
		
		foreach ($data as &$row)
		{
			$row['class']	= $class;
		}
		
		// Return grid
		
		return array (
			'total'	=> $count,
			'rows'	=> $data
		);

	}
public static function _getGrid ($params = array (), $relations = array (), &$db = FALSE)
	{
		
		// If no limit has been set

		if (!$params || !isset ($params['limit']))
		{

			// Set default query limit
			
			$params['limit'] = array (0, 50);

		}
		
		// Get data
		
		if ($relations)
		{
			
			$objs	= static::_getObjects ($params, $db);
			$data	= array ();
			
			foreach ($objs as $obj)
			{
				
				$attributes	= is_array ($params['select'])? $params['select'] : explode (',', $params['select']);
				
				foreach ($attributes as &$val)
				{
					$val = trim ($val);
				}
				
				$data[] = $obj->toArray ($attributes, $relations);
				
			}
			
		}
		else
		{
			$data	= static::_getValues ($params, $db);
		}
		
		// Get count
		
		$count	= self::_count ($params, $db);

		// If there was a problem return FALSE

		if ($count === FALSE || $data === FALSE)
		{
			return FALSE;
		}
		
		// Add class (for API XML response)
		
		$class	= self::_getClass ();
		
		foreach ($data as &$row)
		{
			$row['class']	= $class;
		}
		
		// Return grid
		
		return array (
			'total'	=> $count,
			'rows'	=> $data
		);

	}
public static function _getGrid ( $ params = array ( ) , $ relations = array ( ) , & $ db = FALSE ) { // If no limit has been set if ( ! $ params || ! isset ( $ params [ 'limit' ] ) ) { // Set default query limit $ params [ 'limit' ] = array ( 0 , 50 ) ; } // Get data if ( $ relations ) { $ objs = static :: _getObjects ( $ params , $ db ) ; $ data = array ( ) ; foreach ( $ objs as $ obj ) { $ attributes = is_array ( $ params [ 'select' ] ) ? $ params [ 'select' ] : explode ( ',' , $ params [ 'select' ] ) ; foreach ( $ attributes as & $ val ) { $ val = trim ( $ val ) ; } $ data [ ] = $ obj -> toArray ( $ attributes , $ relations ) ; } } else { $ data = static :: _getValues ( $ params , $ db ) ; } // Get count $ count = self :: _count ( $ params , $ db ) ; // If there was a problem return FALSE if ( $ count === FALSE || $ data === FALSE ) { return FALSE ; } // Add class (for API XML response) $ class = self :: _getClass ( ) ; foreach ( $ data as & $ row ) { $ row [ 'class' ] = $ class ; } // Return grid return array ( 'total' => $ count , 'rows' => $ data ) ; }
Return an array of items with total result count
@param array $params Array of query parameters - MUST BE ESCAPED!
@param array $relations Array of related object attributes or tranformed method attributes to return
e.g. related value - 'query_name' => array ('\Sonic\Model\User\Group', 'name')
e.g. tranformed value - 'permission_value' => array ('$this', 'getStringValue')
@param \PDO $db Database connection to use
@return array|boolean
Return an array of items with total result count