Skip to content

Commit f2e1a8f

Browse files
committed
Fixed Custom Based Model - Add Prefix to Tables
1 parent 6e2603b commit f2e1a8f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

hungng/HungNG_Custom_Based_model.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function bind_order_result($order_by_field, $direction = 'desc', $field =
329329
public function build_order_result($order_by_field, $direction = 'desc', $field = 'id', $table = '')
330330
{
331331
if (!empty($table)) {
332-
$tableName = trim($table) . '.';
332+
$tableName = $this->db->dbprefix(trim($table)) . '.';
333333
} else {
334334
$tableName = $this->db->dbprefix($this->tableName) . '.';
335335
}
@@ -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->db->dbprefix($this->tableName);
401+
$tableName = !empty($table) ? $this->db->dbprefix(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->db->dbprefix($this->tableName);
427+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
428428
if ($value !== null) {
429429
if (is_array($value)) {
430430
$this->db->where_in($tableName . '.' . $field, $value);
@@ -576,7 +576,7 @@ public function only_status_is_active($act = true, $field = 'status', $table = '
576576
public function only_status_is_de_active($act = true, $field = 'status', $table = '')
577577
{
578578
if ($act === true) {
579-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
579+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
580580
$useField = !empty($field) ? trim($field) : 'status';
581581
$tableExists = $this->db->table_exists($tableName);
582582
$fieldExists = $this->db->field_exists($useField, $tableName);
@@ -605,7 +605,7 @@ public function only_status_is_de_active($act = true, $field = 'status', $table
605605
*/
606606
public function bind_recursive_from_category($allSubId, $parentId, $field = 'categoryId', $table = '')
607607
{
608-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
608+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
609609
$listID = $this->build_list_id_with_parent_id($allSubId, $parentId);
610610
if (is_array($listID)) {
611611
$this->db->where_in($tableName . '.' . $field, $listID);
@@ -630,7 +630,7 @@ public function bind_recursive_from_category($allSubId, $parentId, $field = 'cat
630630
*/
631631
public function filter_by_primary_id($id, $field = 'id', $table = '')
632632
{
633-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
633+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
634634
if ($id !== null) {
635635
if (is_array($id)) {
636636
$this->db->where_in($tableName . '.' . $field, $id);
@@ -656,7 +656,7 @@ public function filter_by_primary_id($id, $field = 'id', $table = '')
656656
*/
657657
public function build_operator_equal_to($id, $field = 'id', $table = '')
658658
{
659-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
659+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
660660
if ($id !== null) {
661661
if (is_array($id)) {
662662
$this->db->where_in($tableName . '.' . $field, $id);
@@ -682,7 +682,7 @@ public function build_operator_equal_to($id, $field = 'id', $table = '')
682682
*/
683683
public function build_operator_not_equal_to($id, $field = 'id', $table = '')
684684
{
685-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
685+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
686686
if ($id !== null) {
687687
if (is_array($id)) {
688688
$this->db->where_not_in($tableName . '.' . $field, $id);
@@ -708,7 +708,7 @@ public function build_operator_not_equal_to($id, $field = 'id', $table = '')
708708
*/
709709
public function build_operator_less_than_to($id, $field = 'id', $table = '')
710710
{
711-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
711+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
712712
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_LESS_THAN, $id);
713713

714714
return $this->db;
@@ -728,7 +728,7 @@ public function build_operator_less_than_to($id, $field = 'id', $table = '')
728728
*/
729729
public function build_operator_greater_than_to($id, $field = 'id', $table = '')
730730
{
731-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
731+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
732732
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_GREATER_THAN, $id);
733733

734734
return $this->db;
@@ -748,7 +748,7 @@ public function build_operator_greater_than_to($id, $field = 'id', $table = '')
748748
*/
749749
public function build_operator_less_than_or_equal_to($id, $field = 'id', $table = '')
750750
{
751-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
751+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
752752
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_LESS_THAN_OR_EQUAL_TO, $id);
753753

754754
return $this->db;
@@ -768,7 +768,7 @@ public function build_operator_less_than_or_equal_to($id, $field = 'id', $table
768768
*/
769769
public function build_operator_greater_than_or_equal_to($id, $field = 'id', $table = '')
770770
{
771-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
771+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
772772
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $id);
773773

774774
return $this->db;
@@ -788,7 +788,7 @@ public function build_operator_greater_than_or_equal_to($id, $field = 'id', $tab
788788
*/
789789
public function build_operator_space_ship_to($id, $field = 'id', $table = '')
790790
{
791-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
791+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
792792
$this->db->where($tableName . '.' . $field . ' ' . self::OPERATOR_IS_SPACESHIP, $id);
793793

794794
return $this->db;
@@ -1305,7 +1305,7 @@ public function where_update($wheres, $data, $table = '')
13051305

13061306
return 0;
13071307
}
1308-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
1308+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
13091309
$this->prepare_wheres_statement($wheres);
13101310
$this->db->update($tableName, $data);
13111311

@@ -1354,7 +1354,7 @@ public function where_delete($wheres, $data, $table = '')
13541354

13551355
return 0;
13561356
}
1357-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
1357+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
13581358
$this->prepare_wheres_statement($wheres);
13591359
$this->db->delete($tableName, $data);
13601360

@@ -1373,7 +1373,7 @@ public function where_delete($wheres, $data, $table = '')
13731373
*/
13741374
public function request_builder($search, $table = '')
13751375
{
1376-
$tableName = !empty($table) ? trim($table) : $this->db->dbprefix($this->tableName);
1376+
$tableName = !empty($table) ? $this->db->dbprefix(trim($table)) : $this->db->dbprefix($this->tableName);
13771377
if (!empty($search)) {
13781378
foreach ($search as $field => $value) {
13791379
if (!empty($value) && $this->db->field_exists($field, $tableName)) {

0 commit comments

Comments
 (0)