| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class LP_Course_DB |
| 4 |
* |
| 5 |
* @author tungnx |
| 6 |
* @since 3.2.7.5 |
| 7 |
*/ |
| 8 |
|
| 9 |
use LearnPress\Helpers\Singleton; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || exit(); |
| 12 |
|
| 13 |
class LP_User_DB extends LP_Database { |
| 14 |
use singleton; |
| 15 |
|
| 16 |
public function init() { |
| 17 |
parent::__construct(); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Get users |
| 22 |
* |
| 23 |
* @param LP_User_Filter $filter |
| 24 |
* @param int $total_rows |
| 25 |
* |
| 26 |
* @since 4.2.6.9 |
| 27 |
* @version 1.0.0 |
| 28 |
* @return array|object|null|int|string |
| 29 |
* @throws Exception |
| 30 |
*/ |
| 31 |
public function get_users( LP_User_Filter $filter, int &$total_rows = 0 ) { |
| 32 |
$filter->fields = array_merge( $filter->all_fields, $filter->fields ); |
| 33 |
|
| 34 |
if ( empty( $filter->collection ) ) { |
| 35 |
$filter->collection = $this->tb_users; |
| 36 |
} |
| 37 |
|
| 38 |
if ( empty( $filter->collection_alias ) ) { |
| 39 |
$filter->collection_alias = 'u'; |
| 40 |
} |
| 41 |
|
| 42 |
$ca = $filter->collection_alias; |
| 43 |
|
| 44 |
// Find ID |
| 45 |
if ( isset( $filter->ID ) ) { |
| 46 |
$filter->where[] = $this->wpdb->prepare( "AND $ca.ID = %d", $filter->ID ); |
| 47 |
} |
| 48 |
|
| 49 |
$filter = apply_filters( 'lp/user/query/filter', $filter ); |
| 50 |
|
| 51 |
return $this->execute( $filter, $total_rows ); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
|