Your cart is empty!
Build Query
public function onBuildEmployeeSearchQuery(mixed &$query, array &$options) : void
Fires while loading the employee to display.
Description
Trigger hook to manipulate at runtime the query used to load the employee to display under the Employee Details page in the front-end.
Third party plugins can extend the query by applying further conditions or selecting additional data.
Parameters
- &$query
-
(mixed) Either a query builder object or a plain string.
- &$options
-
(array) An array of options.
id_employee
- the ID of the employee to load;id_service
- the ID of the service assigned to the specified employee.
Return Value
None.
Example
The example below auto-unpublishes the employee with ID #5 when we currently are in Summer.
/**
* Trigger hook to manipulate the query at runtime. Third party plugins
* can extend the query by applying further conditions or selecting
* additional data.
*
* @param mixed &$query Either a query builder or a query string.
* @param array &$options An array of options.
*
* @return void
*/
public function onBuildEmployeeSearchQuery(&$query, &$options)
{
// check if we are trying to fetch a specific employee
if ($options['id_employee'] != 5)
{
return;
}
// get current month
$mon = (int) JHtml::_('date', 'now', 'n');
// check if we are in Summer
if (in_array($mon, [6, 7, 8]))
{
// quick statement to always return no rows
$query->where(0);
}
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |
Last Update: 2022-01-28 16:30
Helpful?