You are here

function farm_quantity_log_asset_query in farmOS 7

Build a query to find logs of an asset that defines a quantity.

Parameters

int $asset_id: The asset id to search for.

string $measure: The quantity measure to search for (ie: weight).

string $label: The quantity label to search for.

int $time: Unix timestamp limiter. Only logs before this time will be included. Defaults to the current time. Set to 0 to load the absolute last.

bool|null $done: Whether or not to only show logs that are marked as "done". TRUE will limit to logs that are done, and FALSE will limit to logs that are not done. If this is set to NULL, no filtering will be applied. Defaults to TRUE.

string|null $type: The log type to filter by. If this is NULL, no filtering will be applied.

bool $single: Whether or not to limit the query to a single result. Defaults to TRUE.

Return value

\SelectQuery Returns a SelectQuery object.

1 call to farm_quantity_log_asset_query()
farm_quantity_log_asset in modules/farm/farm_quantity/farm_quantity_log/farm_quantity_log.module
Load logs for an asset with a given quantity measure and/or label.

File

modules/farm/farm_quantity/farm_quantity_log/farm_quantity_log.module, line 159
Farm quantity log module.

Code

function farm_quantity_log_asset_query($asset_id, $measure = NULL, $label = NULL, $time = REQUEST_TIME, $done = TRUE, $type = NULL, $single = TRUE) {

  /**
   * Please read the comments in farm_log_asset_query() to understand how this
   * works, and to be aware of the limitations and responsibilities we have in
   * this function with regard to sanitizing query inputs.
   */

  // Use the farm_log_asset_query() helper function to start a query object.
  $query = farm_log_asset_query($asset_id, $time, $done, $type, $single);

  // Add a query tag to identify where this came from.
  $query
    ->addTag('farm_quantity_log_asset_query');

  // Add quantity filters to the query using a helper function.
  farm_quantity_log_query_add_filters($query, $measure, $label);

  // Return the query object.
  return $query;
}