Start typing to search...

Download Repository – retrieve_single

Please note: Functionality described on this page requires Download Monitor version 4.0 or above.

Downloads in Download Monitor can be fetched via the Download Repository. Retrieve_single is a method of Download Monitor’s download repository service. The method returns a single DLM_Download object with given ID. Retrieve_single throws an Exception if no download with given ID is found.

Signature

PHP
<strong>public</strong> <strong>function</strong> <strong>retrieve_single</strong>( $id );

Parameters

ParameterTypeDefaultDescription
$idintn/aID of the download that needs to be fetched.

Examples

Retrieve Download with ID 4

This snippet retrieves download with ID 4. Notice that the retrieve_single call is wrapped in a try-catch block. This is because the retrieve_single method throws an exception if no Download with given ID is found.

PHP
<strong>try</strong> {
	$download = download_monitor()->service( 'download_repository' )->retrieve_single( 4 );
} <strong>catch</strong> ( <strong>Exception</strong> $exception ) {
	<em>// no download with ID 4 found</em>
}
Was this page helpful?
0 0
Start Protecting your WordPress Downloads

Protect and track downloads on WordPress... What are you waiting for?