USD Logo MySanDiego | Libraries | Torero Store | Find People | A to Z Index | Resources | Jobs
 Prospective Students | Current Students | Alumni, Parents & Friends | Faculty & Employees | Visitors | International
About USDAdmissionsAcademicsNews and EventsAdministrationAthleticsGiving

Complex fields

Complex fields

If you want to add SQL restrictions and calculations to the query, you can do so.

SQL fields

Any field can be replaced with a more complex SQL portion that describes a single data item. The table can be replaced by a join. For example:

$myCalendar->events("Vacations JOIN Employees ON Vacations.EmployeeID=Employees.username", "vacation_date", "CONCAT(first_name, ' ', last_name)");

This will (in MySQL) combine the tables Vacations and Employees on the fields EmployeeID and username. It will concatenate each employee’s first and last name as the event title. Remember that different databases may use different syntax. In SQLite, for example, the same concatenation would be written “first_name || " " || last_name”.

$myCalendar->events("Vacations JOIN Employees ON Vacations.EmployeeID=Employees.username", "vacation_date", "first_name || \" \" || last_name");

The quotes inside the calculation need to be backquoted or PHP will think the parameter is ending.

SQL restrictions

By default, the only restrictions are based on the date. However, you can add further restrictions using:

$myCalendar->restrict('field="value"');

For example,

$myCalendar->restrict('type="alert"');