PluginProbe ʕ •ᴥ•ʔ
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More / 1.9.3.1
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More v1.9.3.1
1.10.1 1.10.0.5 trunk 1.1.4 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.6.1 1.1.7 1.1.7.1 1.1.7.2 1.1.8 1.1.8.1 1.1.8.2 1.1.8.3 1.1.8.4 1.10.0.1 1.10.0.2 1.10.0.3 1.10.0.4 1.2.0 1.2.0.1 1.2.1 1.2.2 1.2.2.1 1.2.2.2 1.2.3 1.2.3.1 1.2.3.2 1.2.4 1.2.4.1 1.2.5 1.2.5.1 1.2.6 1.2.7 1.2.8 1.2.8.1 1.2.9 1.3.0 1.3.1 1.3.1.1 1.3.1.2 1.3.2 1.3.3 1.3.5 1.3.6 1.3.6.1 1.3.6.2 1.3.7.2 1.3.7.3 1.3.7.4 1.3.8 1.3.9.1 1.4.0.1 1.4.1.1 1.4.2 1.4.2.1 1.4.2.2 1.4.3 1.4.4 1.4.4.1 1.4.5 1.4.5.1 1.4.5.2 1.4.5.3 1.4.6 1.4.7.1 1.4.7.2 1.4.8.1 1.4.9 1.5.0.1 1.5.0.3 1.5.0.4 1.5.1 1.5.1.1 1.5.1.3 1.5.2.1 1.5.2.2 1.5.2.3 1.5.3 1.5.3.1 1.5.4.1 1.5.4.2 1.5.5 1.5.5.1 1.5.6 1.5.6.2 1.5.7 1.5.8.2 1.5.9.1 1.5.9.4 1.5.9.5 1.6.0.1 1.6.0.2 1.6.1 1.6.2.2 1.6.2.3 1.6.3.1 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.7 1.6.7.1 1.6.7.2 1.6.7.3 1.6.8 1.6.8.1 1.6.9 1.7.0 1.7.1.1 1.7.1.2 1.7.2 1.7.2.1 1.7.3 1.7.4 1.7.4.1 1.7.4.2 1.7.5.1 1.7.5.2 1.7.5.3 1.7.5.5 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.7.9.1 1.8.0.1 1.8.0.2 1.8.1.1 1.8.1.2 1.8.1.3 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.3.1 1.8.4 1.8.4.1 1.8.5.2 1.8.5.3 1.8.5.4 1.8.6.2 1.8.6.3 1.8.6.4 1.8.7.2 1.8.8.2 1.8.8.3 1.8.9.1 1.8.9.2 1.8.9.4 1.8.9.5 1.8.9.6 1.9.0.1 1.9.0.2 1.9.0.3 1.9.0.4 1.9.1.1 1.9.1.2 1.9.1.3 1.9.1.4 1.9.1.5 1.9.1.6 1.9.2.1 1.9.2.2 1.9.2.3 1.9.3.1 1.9.3.2 1.9.4.1 1.9.4.2 1.9.5 1.9.5.1 1.9.5.2 1.9.6 1.9.6.1 1.9.6.2 1.9.7.1 1.9.7.2 1.9.7.3 1.9.8.1 1.9.8.2 1.9.8.4 1.9.8.7 1.9.9.2 1.9.9.3 1.9.9.4
wpforms-lite / src / Logger / RecordQuery.php
wpforms-lite / src / Logger Last commit date
ListTable.php 1 year ago Log.php 1 year ago Record.php 1 year ago RecordQuery.php 1 year ago Records.php 1 year ago Repository.php 1 year ago
RecordQuery.php
81 lines
1 <?php
2
3 // phpcs:ignore Generic.Commenting.DocComment.MissingShort
4 /** @noinspection PhpIllegalPsrClassPathInspection */
5
6 namespace WPForms\Logger;
7
8 /**
9 * Class RecordQuery.
10 *
11 * @since 1.6.3
12 */
13 class RecordQuery {
14
15 /**
16 * Build query.
17 *
18 * @since 1.6.3
19 *
20 * @param int $limit Query limit of records.
21 * @param int $offset Offset of records.
22 * @param string $search Search.
23 * @param string $type Type of records.
24 *
25 * @return array
26 */
27 public function get( $limit, $offset = 0, $search = '', $type = '' ) {
28
29 global $wpdb;
30 //phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
31 return (array) $wpdb->get_results(
32 $this->build_query( $limit, $offset, $search, $type )
33 );
34 //phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
35 }
36
37 /**
38 * Build query.
39 *
40 * @since 1.6.3
41 *
42 * @param int $limit Query limit of records.
43 * @param int $offset Offset of records.
44 * @param string $search Search.
45 * @param string $type Type of records.
46 *
47 * @return string
48 */
49 private function build_query( $limit, $offset = 0, $search = '', $type = '' ) {
50
51 global $wpdb;
52
53 $sql = 'SELECT SQL_CALC_FOUND_ROWS * FROM ' . Repository::get_table_name();
54 $where = [];
55
56 if ( ! empty( $search ) ) {
57 $where[] = $wpdb->prepare(
58 '`title` REGEXP %s OR `message` REGEXP %s',
59 $search,
60 $search
61 );
62 }
63
64 if ( ! empty( $type ) ) {
65 $where[] = $wpdb->prepare(
66 '`types` REGEXP %s',
67 $type
68 );
69 }
70
71 if ( $where ) {
72 $sql .= ' WHERE ' . implode( ' AND ', $where );
73 }
74
75 $sql .= ' ORDER BY `create_at` DESC, `id` DESC';
76 $sql .= $wpdb->prepare( ' LIMIT %d, %d', absint( $offset ), absint( $limit ) );
77
78 return $sql;
79 }
80 }
81