PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.2
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / databases / class-lp-sessions-db.php

class-lp-sessions-db.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7.2, at inc/databases/class-lp-sessions-db.php

71 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 /**
8 * Class LP_Sessions_DB
9 *
10 * @since 4.1.1
11 */
12 class LP_Sessions_DB extends LP_Database {
13 private static $_instance;
14
15 protected function __construct() {
16 parent::__construct();
17 }
18
19 public static function getInstance() {
20 if ( is_null( self::$_instance ) ) {
21 self::$_instance = new self();
22 }
23
24 return self::$_instance;
25 }
26
27 /**
28 * Get delete rows in session table
29 *
30 * @throws
31 */
32 public function delete_rows() {
33 $now = current_time( 'timestamp' );
34 $adayago = $now - ( 24 * 60 * 60 );
35 $where = 'WHERE session_expiry < ' . $adayago . '';
36 $table = $this->tb_lp_sessions;
37 $limit = 100;
38 $result = $this->wpdb->query(
39 "
40 DELETE FROM {$table}
41 {$where}
42 LIMIT {$limit}
43 "
44 );
45
46 $this->check_execute_has_error();
47
48 return $result;
49 }
50 public function count_row_db_sessions() {
51 global $wpdb;
52 $now = current_time( 'timestamp' );
53 $adayago = $now - ( 24 * 60 * 60 );
54 $where = 'WHERE session_expiry < ' . $adayago . ' AND 0=%d';
55 $query = $wpdb->prepare(
56 "
57 SELECT count(*)
58 FROM $this->tb_lp_sessions
59 {$where}
60 ",
61 0
62 );
63
64 $result = $wpdb->get_var( $query );
65 return $result;
66 }
67 }
68
69 LP_Sessions_DB::getInstance();
70
71