Skip to content

Commit c2c524c

Browse files
authored
Merge pull request #26 from nguyenanhung/v3.2.0-develop
V3.2.0 develop
2 parents 5af7cd9 + eb696f7 commit c2c524c

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

hungng/HungNG_Custom_Based_model.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function build_order_result($order_by_field, $direction = 'desc', $field
331331
if (!empty($table)) {
332332
$tableName = trim($table) . '.';
333333
} else {
334-
$tableName = $this->tableName . '.';
334+
$tableName = $this->db->dbprefix($this->tableName) . '.';
335335
}
336336
if ($table === 'order_by_field') {
337337
$tableName = '';
@@ -398,7 +398,7 @@ public function build_list_id_with_parent_id($allSubId, $parentId)
398398
*/
399399
public function prepare_simple_wheres_not_statement($value, $field = 'id', $table = '')
400400
{
401-
$tableName = !empty($table) ? trim($table) : $this->tableName;
401+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
402402
if ($value !== null) {
403403
if (is_array($value)) {
404404
$this->db->where_not_in($tableName . '.' . $field, $value);
@@ -424,7 +424,7 @@ public function prepare_simple_wheres_not_statement($value, $field = 'id', $tabl
424424
*/
425425
public function prepare_simple_wheres_statement($value, $field = 'id', $table = '')
426426
{
427-
$tableName = !empty($table) ? trim($table) : $this->tableName;
427+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
428428
if ($value !== null) {
429429
if (is_array($value)) {
430430
$this->db->where_in($tableName . '.' . $field, $value);
@@ -546,7 +546,7 @@ public function only_status_is_active($act = true, $field = 'status', $table = '
546546
public function only_status_is_de_active($act = true, $field = 'status', $table = '')
547547
{
548548
if ($act === true) {
549-
$tableName = !empty($table) ? trim($table) : $this->tableName;
549+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
550550
$useField = !empty($field) ? trim($field) : 'status';
551551
$tableExists = $this->db->table_exists($tableName);
552552
$fieldExists = $this->db->field_exists($useField, $tableName);
@@ -575,7 +575,7 @@ public function only_status_is_de_active($act = true, $field = 'status', $table
575575
*/
576576
public function bind_recursive_from_category($allSubId, $parentId, $field = 'categoryId', $table = '')
577577
{
578-
$tableName = !empty($table) ? trim($table) : $this->tableName;
578+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
579579
$listID = $this->build_list_id_with_parent_id($allSubId, $parentId);
580580
if (is_array($listID)) {
581581
$this->db->where_in($tableName . '.' . $field, $listID);
@@ -600,7 +600,7 @@ public function bind_recursive_from_category($allSubId, $parentId, $field = 'cat
600600
*/
601601
public function filter_by_primary_id($id, $field = 'id', $table = '')
602602
{
603-
$tableName = !empty($table) ? trim($table) : $this->tableName;
603+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
604604
if ($id !== null) {
605605
if (is_array($id)) {
606606
$this->db->where_in($tableName . '.' . $field, $id);
@@ -626,7 +626,7 @@ public function filter_by_primary_id($id, $field = 'id', $table = '')
626626
*/
627627
public function build_operator_equal_to($id, $field = 'id', $table = '')
628628
{
629-
$tableName = !empty($table) ? trim($table) : $this->tableName;
629+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
630630
if ($id !== null) {
631631
if (is_array($id)) {
632632
$this->db->where_in($tableName . '.' . $field, $id);
@@ -652,7 +652,7 @@ public function build_operator_equal_to($id, $field = 'id', $table = '')
652652
*/
653653
public function build_operator_not_equal_to($id, $field = 'id', $table = '')
654654
{
655-
$tableName = !empty($table) ? trim($table) : $this->tableName;
655+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
656656
if ($id !== null) {
657657
if (is_array($id)) {
658658
$this->db->where_not_in($tableName . '.' . $field, $id);
@@ -678,7 +678,7 @@ public function build_operator_not_equal_to($id, $field = 'id', $table = '')
678678
*/
679679
public function build_operator_less_than_to($id, $field = 'id', $table = '')
680680
{
681-
$tableName = !empty($table) ? trim($table) : $this->tableName;
681+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
682682
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_LESS_THAN, $id);
683683

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

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

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

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

764764
return $this->db;
@@ -1060,20 +1060,21 @@ public function get_list_distinct($field = '*')
10601060
*/
10611061
public function get_data_simple_result($select = '*', $wheres = array(), $size = 75, $page = 0, $orderBy = array('id' => 'DESC'))
10621062
{
1063+
$tableName = $this->db->dbprefix($this->tableName);
10631064
$this->db->select($select);
10641065
$this->db->from($this->tableName);
10651066
if (count($wheres) > 0) {
10661067
foreach ($wheres as $field => $value) {
10671068
if (is_array($value)) {
1068-
$this->db->where_in($this->tableName . '.' . $field, $value);
1069+
$this->db->where_in($tableName . '.' . $field, $value);
10691070
} else {
1070-
$this->db->where($this->tableName . '.' . $field, $value);
1071+
$this->db->where($tableName . '.' . $field, $value);
10711072
}
10721073
}
10731074
}
10741075
$this->page_limit($size, $page);
10751076
foreach ($orderBy as $key => $val) {
1076-
$this->db->order_by($this->tableName . '.' . $key, $val);
1077+
$this->db->order_by($tableName . '.' . $key, $val);
10771078
}
10781079

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

12451246
return 0;
12461247
}
1247-
$tableName = !empty($table) ? trim($table) : $this->tableName;
1248+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
12481249
$this->prepare_wheres_statement($wheres);
12491250
$this->db->update($tableName, $data);
12501251

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

12941295
return 0;
12951296
}
1296-
$tableName = !empty($table) ? trim($table) : $this->tableName;
1297+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
12971298
$this->prepare_wheres_statement($wheres);
12981299
$this->db->delete($tableName, $data);
12991300

@@ -1312,7 +1313,7 @@ public function where_delete($wheres, $data, $table = '')
13121313
*/
13131314
public function request_builder($search, $table = '')
13141315
{
1315-
$tableName = !empty($table) ? trim($table) : $this->tableName;
1316+
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
13161317
if (!empty($search)) {
13171318
foreach ($search as $field => $value) {
13181319
if (!empty($value) && $this->db->field_exists($field, $tableName)) {

0 commit comments

Comments
 (0)