Skip to content

Commit

Permalink
Merge pull request #26 from nguyenanhung/v3.2.0-develop
Browse files Browse the repository at this point in the history
V3.2.0 develop
  • Loading branch information
hungnguyenhp authored Mar 27, 2023
2 parents 5af7cd9 + eb696f7 commit c2c524c
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions hungng/HungNG_Custom_Based_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function build_order_result($order_by_field, $direction = 'desc', $field
if (!empty($table)) {
$tableName = trim($table) . '.';
} else {
$tableName = $this->tableName . '.';
$tableName = $this->db->dbprefix($this->tableName) . '.';
}
if ($table === 'order_by_field') {
$tableName = '';
Expand Down Expand Up @@ -398,7 +398,7 @@ public function build_list_id_with_parent_id($allSubId, $parentId)
*/
public function prepare_simple_wheres_not_statement($value, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
if ($value !== null) {
if (is_array($value)) {
$this->db->where_not_in($tableName . '.' . $field, $value);
Expand All @@ -424,7 +424,7 @@ public function prepare_simple_wheres_not_statement($value, $field = 'id', $tabl
*/
public function prepare_simple_wheres_statement($value, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
if ($value !== null) {
if (is_array($value)) {
$this->db->where_in($tableName . '.' . $field, $value);
Expand Down Expand Up @@ -546,7 +546,7 @@ public function only_status_is_active($act = true, $field = 'status', $table = '
public function only_status_is_de_active($act = true, $field = 'status', $table = '')
{
if ($act === true) {
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$useField = !empty($field) ? trim($field) : 'status';
$tableExists = $this->db->table_exists($tableName);
$fieldExists = $this->db->field_exists($useField, $tableName);
Expand Down Expand Up @@ -575,7 +575,7 @@ public function only_status_is_de_active($act = true, $field = 'status', $table
*/
public function bind_recursive_from_category($allSubId, $parentId, $field = 'categoryId', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$listID = $this->build_list_id_with_parent_id($allSubId, $parentId);
if (is_array($listID)) {
$this->db->where_in($tableName . '.' . $field, $listID);
Expand All @@ -600,7 +600,7 @@ public function bind_recursive_from_category($allSubId, $parentId, $field = 'cat
*/
public function filter_by_primary_id($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
if ($id !== null) {
if (is_array($id)) {
$this->db->where_in($tableName . '.' . $field, $id);
Expand All @@ -626,7 +626,7 @@ public function filter_by_primary_id($id, $field = 'id', $table = '')
*/
public function build_operator_equal_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
if ($id !== null) {
if (is_array($id)) {
$this->db->where_in($tableName . '.' . $field, $id);
Expand All @@ -652,7 +652,7 @@ public function build_operator_equal_to($id, $field = 'id', $table = '')
*/
public function build_operator_not_equal_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
if ($id !== null) {
if (is_array($id)) {
$this->db->where_not_in($tableName . '.' . $field, $id);
Expand All @@ -678,7 +678,7 @@ public function build_operator_not_equal_to($id, $field = 'id', $table = '')
*/
public function build_operator_less_than_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_LESS_THAN, $id);

return $this->db;
Expand All @@ -698,7 +698,7 @@ public function build_operator_less_than_to($id, $field = 'id', $table = '')
*/
public function build_operator_greater_than_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_GREATER_THAN, $id);

return $this->db;
Expand All @@ -718,7 +718,7 @@ public function build_operator_greater_than_to($id, $field = 'id', $table = '')
*/
public function build_operator_less_than_or_equal_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_LESS_THAN_OR_EQUAL_TO, $id);

return $this->db;
Expand All @@ -738,7 +738,7 @@ public function build_operator_less_than_or_equal_to($id, $field = 'id', $table
*/
public function build_operator_greater_than_or_equal_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $id);

return $this->db;
Expand All @@ -758,7 +758,7 @@ public function build_operator_greater_than_or_equal_to($id, $field = 'id', $tab
*/
public function build_operator_space_ship_to($id, $field = 'id', $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_IS_SPACESHIP, $id);

return $this->db;
Expand Down Expand Up @@ -1060,20 +1060,21 @@ public function get_list_distinct($field = '*')
*/
public function get_data_simple_result($select = '*', $wheres = array(), $size = 75, $page = 0, $orderBy = array('id' => 'DESC'))
{
$tableName = $this->db->dbprefix($this->tableName);
$this->db->select($select);
$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);
$this->db->where_in($tableName . '.' . $field, $value);
} else {
$this->db->where($this->tableName . '.' . $field, $value);
$this->db->where($tableName . '.' . $field, $value);
}
}
}
$this->page_limit($size, $page);
foreach ($orderBy as $key => $val) {
$this->db->order_by($this->tableName . '.' . $key, $val);
$this->db->order_by($tableName . '.' . $key, $val);
}

return $this->db->get()->result();
Expand Down Expand Up @@ -1244,7 +1245,7 @@ public function where_update($wheres, $data, $table = '')

return 0;
}
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->prepare_wheres_statement($wheres);
$this->db->update($tableName, $data);

Expand Down Expand Up @@ -1293,7 +1294,7 @@ public function where_delete($wheres, $data, $table = '')

return 0;
}
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
$this->prepare_wheres_statement($wheres);
$this->db->delete($tableName, $data);

Expand All @@ -1312,7 +1313,7 @@ public function where_delete($wheres, $data, $table = '')
*/
public function request_builder($search, $table = '')
{
$tableName = !empty($table) ? trim($table) : $this->tableName;
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
if (!empty($search)) {
foreach ($search as $field => $value) {
if (!empty($value) && $this->db->field_exists($field, $tableName)) {
Expand Down

0 comments on commit c2c524c

Please sign in to comment.