WC_Customer_Download_Log_Data_Store::read()publicWC 1.0

Method to read a download log from the database.

Method of the class: WC_Customer_Download_Log_Data_Store{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Customer_Download_Log_Data_Store = new WC_Customer_Download_Log_Data_Store();
$WC_Customer_Download_Log_Data_Store->read( $download_log );
$download_log(WC_Customer_Download_Log) (required) (passed by reference — &)
Download log object.

WC_Customer_Download_Log_Data_Store::read() code WC 9.4.2

public function read( &$download_log ) {
	global $wpdb;

	$download_log->set_defaults();

	// Ensure we have an id to pull from the DB.
	if ( ! $download_log->get_id() ) {
		throw new Exception( __( 'Invalid download log: no ID.', 'woocommerce' ) );
	}

	$table = $wpdb->prefix . self::get_table_name();

	// Query the DB for the download log.
	$raw_download_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table} WHERE download_log_id = %d", $download_log->get_id() ) ); // WPCS: unprepared SQL ok.

	if ( ! $raw_download_log ) {
		throw new Exception( __( 'Invalid download log: not found.', 'woocommerce' ) );
	}

	$download_log->set_props(
		array(
			'timestamp'       => strtotime( $raw_download_log->timestamp ),
			'permission_id'   => $raw_download_log->permission_id,
			'user_id'         => $raw_download_log->user_id,
			'user_ip_address' => $raw_download_log->user_ip_address,
		)
	);

	$download_log->set_object_read( true );
}