Skip to content

Commit

Permalink
add function get_data_simple_result
Browse files Browse the repository at this point in the history
  • Loading branch information
hungnguyenhp committed Sep 13, 2021
1 parent dcbfd56 commit 0909fa5
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions hungng/HungNG_Custom_Based_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,43 @@ public function get_list_distinct($field = '*')
return $this->db->get()->result();
}

/**
* Function get_data_simple_result
*
* @param string $selectField
* @param array $wheres
* @param int $size
* @param int $page
* @param string[] $orderBy
*
* @return array|array[]|object|object[]
* @author : 713uk13m <dev@nguyenanhung.com>
* @copyright: 713uk13m <dev@nguyenanhung.com>
* @time : 09/13/2021 16:49
*/
public function get_data_simple_result($selectField = '*', $wheres = [], $size = 75, $page = 0, $orderBy = ['id' => 'DESC'])
{
$this->db->select($selectField);
$this->db->from($this->tableName);
if (count($wheres) > 0) {
foreach ($wheres as $field => $value) {
if (is_array($value)) {
$this->db->where_in($this->tableName . '.' . $field, $value);
} else {
$this->db->where($this->tableName . '.' . $field, $value);
}
}
}
// Limit Result
self::_page_limit($size, $page);
// Order Result
foreach ($orderBy as $key => $val) {
$this->db->order_by($this->tableName . '.' . $key, $val);
}

return $this->db->get()->result();
}

/**
* Function get_info
*
Expand Down

0 comments on commit 0909fa5

Please sign in to comment.