Skip to content

Commit

Permalink
This doesn't work in my local sqlite, but should work in playground.
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed May 10, 2024
1 parent 9b5e83e commit 2c3b1c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/my-calendar-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ function mc_get_all_events( $args ) {
$limit = "$select_published $select_category $select_author $select_host $select_access $search $select_window";

// New Query style.
$total = absint( $before ) + absint( $after ) + 30;
$events = $mcdb->get_results(
$total = absint( $before ) + absint( $after ) + 30;
$db_engine = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';
$ordering = ( 'sqlite' === $db_engine ) ? 'ABS( ( SELECT unixepoch() ) - ( SELECT unixepoch(occur_begin) ))' : 'ABS(TIMESTAMPDIFF(SECOND, NOW(), occur_begin))';
$events = $mcdb->get_results(
'SELECT *, ' . $ts_string . '
FROM ' . my_calendar_event_table( $site ) . '
JOIN ' . my_calendar_table( $site ) . " AS e
Expand All @@ -363,7 +365,7 @@ function mc_get_all_events( $args ) {
ON (e.event_category=c.category_id)
WHERE $limit
$exclude_categories
ORDER BY ABS(TIMESTAMPDIFF(SECOND, NOW(), occur_begin)) ASC LIMIT 0,$total"
ORDER BY $ordering ASC LIMIT 0,$total"
);

$cats = array();
Expand Down

0 comments on commit 2c3b1c8

Please sign in to comment.