public static function _toJSON ($params = array (), $attributes = FALSE, $addClass = FALSE, &$db = FALSE)
	{
		
		// Get objects
		
		$rows	= static::_toArray ($params, $attributes, $db);
		
		// Add the class name if required
		
		if ($addClass)
		{
					
			// Set class name for the elements
			// Remove the Sonic\Model prefix and convert namespace \ to _

			$class	= str_replace ('\\', '_', str_replace ('sonic\\model\\', '', strtolower (get_called_class ())));
			
			foreach ($rows as &$row)
			{
				$row['class']	= $class;
			}
			
		}
		
		// Return json encoded
		
		return json_encode ($rows);
		
	}
public static function _toJSON ($params = array (), $attributes = FALSE, $addClass = FALSE, &$db = FALSE)
	{
		
		// Get objects
		
		$rows	= static::_toArray ($params, $attributes, $db);
		
		// Add the class name if required
		
		if ($addClass)
		{
					
			// Set class name for the elements
			// Remove the Sonic\Model prefix and convert namespace \ to _

			$class	= str_replace ('\\', '_', str_replace ('sonic\\model\\', '', strtolower (get_called_class ())));
			
			foreach ($rows as &$row)
			{
				$row['class']	= $class;
			}
			
		}
		
		// Return json encoded
		
		return json_encode ($rows);
		
	}
public static function _toJSON ( $ params = array ( ) , $ attributes = FALSE , $ addClass = FALSE , & $ db = FALSE ) { // Get objects $ rows = static :: _toArray ( $ params , $ attributes , $ db ) ; // Add the class name if required if ( $ addClass ) { // Set class name for the elements // Remove the Sonic\Model prefix and convert namespace \ to _ $ class = str_replace ( '\\' , '_' , str_replace ( 'sonic\\model\\' , '' , strtolower ( get_called_class ( ) ) ) ) ; foreach ( $ rows as & $ row ) { $ row [ 'class' ] = $ class ; } } // Return json encoded return json_encode ( $ rows ) ; }
Return a JSON encoded string with objects for given query parameters
@param array $params Parameter array
@param array|boolean $attributes Attributes to include, default to false i.e all attributes
@param boolean $addClass Whether to add the class name to each exported object
@param \PDO $db Database connection to use
@return object|boolean
Return a JSON encoded string with objects for given query parameters