WC_Customer_Download_Log_Data_Store::read( WC_Customer_Download_Log $download_log )

Method to read a download log from the database.


Description Description


Parameters Parameters

$download_log

(Required) Download log object.


Top ↑

Source Source

File: includes/data-stores/class-wc-customer-download-log-data-store.php

	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 );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.