Function to enable SQL_CALC_FOUND_ROWS in the get queries
public withTotalCount ( ) : MysqliDb | ||
Результат | MysqliDb |
/** * Pagination wraper to get() * * @access public * @param int $page Page number * @param array|string $fields Array or coma separated list of fields to fetch * @return array */ private function paginate($page, $fields = null) { $offset = $this->pageLimit * ($page - 1); $this->db->withTotalCount(); $results = $this->get(array($this->pageLimit, $offset), $fields); $this->totalPages = round($this->db->totalCount / $this->pageLimit); return $results; }
$db2->where('action LIKE "%' . $_POST['search_term'] . '%"'); } else { $db->where('action LIKE "%%"'); $db2->where('action LIKE "%%"'); } if (isset($_POST['user']) && $_POST['user'] != null) { $db->where('user_id="' . $_POST['user'] . '"'); $db2->where('user_id="' . $_POST['user'] . '"'); } else { $db->where('user_id LIKE "%%"'); $db2->where('user_id LIKE "%%"'); } $db->orderBy("date_time", "DESC"); $results = $db->get("log_activity", array($limitFrom, $pageLimit)); //$db->echoQuery(); $db2->withTotalCount()->get("log_activity"); $total_log = $db2->totalCount; echo '<div class="total-number-customers" align="center"><span class="badge badge-success">' . $total_log . ' logs found!</span></div>'; if ($results) { ?> <table class="table-font-size table table-striped" id="dataTable"> <thead> <tr> <th>#</th> <th>Action</th> <th>User</th> <th>Date Time</th> </tr> </thead> <tbody>
$db->orWhere('name LIKE "%%"'); $db->orWhere('lastname LIKE "%%")'); $db2->where('(username LIKE "%%"'); $db2->orWhere('name LIKE "%%"'); $db2->orWhere('lastname LIKE "%%")'); } if (isset($_POST['status']) && $_POST['status'] != null) { $db->where('status="' . $_POST['status'] . '"'); $db2->where('status="' . $_POST['status'] . '"'); } else { $db->where('status LIKE "%%"'); $db2->where('status LIKE "%%"'); } $results = $db->get("users", array($limitFrom, $pageLimit)); //$db->echoQuery(); $db2->withTotalCount()->get("users"); //$db2->echoQuery(); $total_users = $db2->totalCount; echo '<div class="total-number-customers" align="center"><span class="badge badge-success">' . $total_users . ' users found!</span></div>'; if ($results) { ?> <table class="table-font-size table table-striped" id="dataTable"> <thead> <tr> <th>#</th> <th>Name</th> <th>Lastname</th> <th>Email</th> <th>Username</th> <th>Backend Login</th> <th>Edit</th>
$db->where('category="' . $_POST['category'] . '"'); $db2->where('category="' . $_POST['category'] . '"'); } else { $db->where('category LIKE "%%"'); $db2->where('category LIKE "%%"'); } if (isset($_POST['status']) && $_POST['status'] != null) { $db->where('status="' . $_POST['status'] . '"'); $db2->where('status="' . $_POST['status'] . '"'); } else { $db->where('status LIKE "%%"'); $db2->where('status LIKE "%%"'); } $results = $db->get("product", array($limitFrom, $pageLimit)); //$db->echoQuery(); $db2->withTotalCount()->get("product"); //$db2->echoQuery(); $total_products = $db2->totalCount; echo '<div class="total-number-customers" align="center"><span class="badge badge-success">' . $total_products . ' products found!</span></div>'; if ($results) { ?> <table class="table-font-size table table-striped" id="dataTable"> <thead> <tr> <th>#</th> <th>Item Code</th> <th>Barcode</th> <th>Description</th> <th>Supplier</th> <th>Category</th> <th>W/Sale</th>
$db2->where('region="' . $_POST['region'] . '"'); } else { $db->where('region LIKE "%%"'); $db2->where('region LIKE "%%"'); } //Status if (isset($_POST['status']) && $_POST['status'] != null) { $db->where('status="' . $_POST['status'] . '"'); $db2->where('status="' . $_POST['status'] . '"'); } else { $db->where('status LIKE "%%"'); $db2->where('status LIKE "%%"'); } $results = $db->get("customer", array($limitFrom, $pageLimit)); //$db->echoQuery(); $db2->withTotalCount()->get("customer"); //$db2->echoQuery(); $total_customers = $db2->totalCount; echo '<div class="total-number-customers" align="center"><span class="badge badge-success">' . $total_customers . ' customers found!</span></div>'; if ($results) { ?> <table class="table-font-size table table-striped" id="dataTable"> <thead> <tr> <th>#</th> <th>Card</th> <th>Group</th> <th>Region</th> <th>City</th> <th>Phone 1</th> <th>Edit</th>