public function onLoadRestaurantReservationDetails( mixed &$query, int $id, mixed $langtag, array $options ) : void

Fires while creating the query used to load the details of a restaurant reservation.


Description

External plugins can attach to this hook in order to manipulate the query at runtime, useful to include some details that are not fetched by default.


Parameters

&$query

(string|JDatabaseQuery)  Either a query string or a query builder instance.

$id

(int)  The ID of the reservation to load.

$langtag

(null/string)  An optional language tag for i18n support.

$options

(array)  An associative array containing a few loading options.

Return Value

None.


Example

The example below can be used to override the ordering of the query, by sorting the purchased products with their specified ordering.

/**
 * External plugins can attach to this hook in order to manipulate
 * the query at runtime, in example to alter the default ordering.
 *
 * @param 	mixed    &$query   A query builder instance.
 * @param 	integer  $id       The ID of the reservation.
 * @param 	mixed    $langtag  The language tag. If null, the default one will be used.
 * @param 	array 	 $options  An array of options to be passed to the order instance.
 *
 * @return  void
 */
public function onLoadRestaurantReservationDetails(&$query, $id, $langtag, $options)
{
    $dbo = JFactory::getDbo();

    // let's load the product image too
    $query->select($dbo->qn('sp.image', 'product_image'));

    // join table holding the details of the product with the table of the purchased items
    $query->leftjoin($dbo->qn('#__vikrestaurants_section_product', 'sp') . ' ON ' . $dbo->qn('i.id_product') . ' = ' . $dbo->qn('sp.id'));

    // clear any other ordering
    $query->clear('order');
    // set our new ordering
    $query->order($dbo->qn('sp.ordering') . ' ASC');
}

Changelog

Version Description
1.8.4 Introduced.
Last Update: 2023-12-29 14:15
Helpful?
See Also: