-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c06672
commit 2962530
Showing
2 changed files
with
34 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,6 +243,6 @@ class TestModule extends HungNG_CI_Base_Module | |
## Liên hệ | ||
|
||
| Name | Email | Skype | Facebook | | ||
| ----------- | -------------------- | ---------------- | ------------- | | ||
|-------------|----------------------|------------------|---------------| | ||
| Hung Nguyen | [email protected] | nguyenanhung5891 | @nguyenanhung | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,7 +159,7 @@ public function page_limit($size = 500, $page = 0) | |
{ | ||
if ($size !== 'no_limit') { | ||
if ($page !== 0) { | ||
if (!$page || $page <= 0 || empty($page)) { | ||
if ($page <= 0 || empty($page)) { | ||
$page = 1; | ||
} | ||
$start = ($page - 1) * $size; | ||
|
@@ -235,6 +235,34 @@ public function get_last_id($field = 'id') | |
return 0; | ||
} | ||
|
||
public function get_first_id($field = 'id') | ||
{ | ||
$this->db->select($field); | ||
$this->db->from($this->tableName); | ||
$this->db->limit(1); | ||
$this->db->order_by($field, 'ASC'); | ||
$row = $this->db->get()->row(); | ||
if (is_object($row)) { | ||
return $row->$field; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
public function get_random_id($field = 'id') | ||
{ | ||
$this->db->select($field); | ||
$this->db->from($this->tableName); | ||
$this->db->limit(1); | ||
$this->db->order_by($field, 'RANDOM'); | ||
$row = $this->db->get()->row(); | ||
if (is_object($row)) { | ||
return $row->$field; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* Function get_all | ||
* | ||
|
@@ -325,7 +353,7 @@ public function get_list_distinct($field = '*') | |
/** | ||
* Function get_data_simple_result | ||
* | ||
* @param string $selectField | ||
* @param string $select | ||
* @param array $wheres | ||
* @param int $size | ||
* @param int $page | ||
|
@@ -336,9 +364,9 @@ public function get_list_distinct($field = '*') | |
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/13/2021 16:49 | ||
*/ | ||
public function get_data_simple_result($selectField = '*', $wheres = [], $size = 75, $page = 0, $orderBy = ['id' => 'DESC']) | ||
public function get_data_simple_result($select = '*', $wheres = [], $size = 75, $page = 0, $orderBy = ['id' => 'DESC']) | ||
{ | ||
$this->db->select($selectField); | ||
$this->db->select($select); | ||
$this->db->from($this->tableName); | ||
if (count($wheres) > 0) { | ||
foreach ($wheres as $field => $value) { | ||
|
@@ -372,7 +400,7 @@ public function get_data_simple_result($selectField = '*', $wheres = [], $size = | |
public function get_all_data_simple_result($options = null) | ||
{ | ||
$this->db->from($this->tableName); | ||
if (($options !== null) && is_array($options)) { | ||
if (is_array($options)) { | ||
foreach ($options as $field => $value) { | ||
if (is_array($value)) { | ||
$this->db->where_in($field, $value); | ||
|