Skip to content

Commit 3d0cdcb

Browse files
committed
Upgrade HungNG_Custom_Based_model
1 parent 672b3a3 commit 3d0cdcb

File tree

2 files changed

+103
-9
lines changed

2 files changed

+103
-9
lines changed

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "The CodeIgniter framework - v3.1.13",
2+
"description": "The CodeIgniter framework - v3.1.14",
33
"name": "nguyenanhung/codeigniter-framework",
44
"type": "library",
55
"homepage": "https://codeigniter.com",
@@ -13,10 +13,9 @@
1313
}
1414
],
1515
"support": {
16-
"forum": "https://forum.codeigniter.com/",
17-
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
18-
"slack": "https://codeigniterchat.slack.com",
19-
"source": "https://github.com/bcit-ci/CodeIgniter"
16+
"issues": "https://github.com/nguyenanhung/codeigniter-framework/issues",
17+
"wiki": "https://github.com/nguyenanhung/codeigniter-framework/wiki",
18+
"source": "https://github.com/nguyenanhung/codeigniter-framework"
2019
},
2120
"require": {
2221
"php": ">=5.6",
@@ -25,7 +24,7 @@
2524
"nguyenanhung/codeigniter-basic-helper": ">=1.0"
2625
},
2726
"require-dev": {
28-
"nguyenanhung/my-debug": "^3.0 || ^2.0 || ^1.0"
27+
"nguyenanhung/my-debug": "^4.0 || ^3.0 || ^2.0 || ^1.0"
2928
},
3029
"autoload": {
3130
"classmap": [

hungng/HungNG_Custom_Based_model.php

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,82 @@ public function build_operator_space_ship_to($id, $field = 'id', $table = '')
743743
return $this->db;
744744
}
745745

746+
// ------------------------------------------ Database Metadata ------------------------------------------ //
747+
748+
/**
749+
* Function list_tables
750+
*
751+
* @return array|false|string
752+
* @author : 713uk13m <dev@nguyenanhung.com>
753+
* @copyright: 713uk13m <dev@nguyenanhung.com>
754+
* @time : 16/02/2023 21:09
755+
*/
756+
public function list_tables()
757+
{
758+
return $this->db->list_tables();
759+
}
760+
761+
/**
762+
* Function table_exists
763+
*
764+
* @param $table
765+
*
766+
* @return bool
767+
* @author : 713uk13m <dev@nguyenanhung.com>
768+
* @copyright: 713uk13m <dev@nguyenanhung.com>
769+
* @time : 16/02/2023 25:08
770+
*/
771+
public function table_exists($table)
772+
{
773+
return $this->db->table_exists($table);
774+
}
775+
776+
/**
777+
* Function list_fields_on_table
778+
*
779+
* @param $table
780+
*
781+
* @return array|false|string
782+
* @author : 713uk13m <dev@nguyenanhung.com>
783+
* @copyright: 713uk13m <dev@nguyenanhung.com>
784+
* @time : 16/02/2023 25:23
785+
*/
786+
public function list_fields_on_table($table)
787+
{
788+
return $this->db->list_fields($table);
789+
}
790+
791+
/**
792+
* Function field_exists_on_table
793+
*
794+
* @param $field
795+
* @param $table
796+
*
797+
* @return bool
798+
* @author : 713uk13m <dev@nguyenanhung.com>
799+
* @copyright: 713uk13m <dev@nguyenanhung.com>
800+
* @time : 16/02/2023 26:47
801+
*/
802+
public function field_exists_on_table($field, $table)
803+
{
804+
return $this->db->field_exists($field, $table);
805+
}
806+
807+
/**
808+
* Function list_all_field_data
809+
*
810+
* @param $table
811+
*
812+
* @return array|false
813+
* @author : 713uk13m <dev@nguyenanhung.com>
814+
* @copyright: 713uk13m <dev@nguyenanhung.com>
815+
* @time : 16/02/2023 26:44
816+
*/
817+
public function list_all_field_data($table)
818+
{
819+
return $this->db->field_data($table);
820+
}
821+
746822
// ---------------------------------------------------------------------------------------------------------------------------------------- //
747823

748824
/**
@@ -758,7 +834,7 @@ public function build_operator_space_ship_to($id, $field = 'id', $table = '')
758834
*/
759835
public function check_exists($value = '', $field = null)
760836
{
761-
$this->db->select('id');
837+
$this->db->select($this->primary_key);
762838
$this->db->from($this->tableName);
763839
if ($field === null) {
764840
$this->db->where($this->primary_key, $value);
@@ -862,12 +938,12 @@ public function get_all($field = '*')
862938
/**
863939
* Function get_all_asc
864940
*
865-
* @param string $field
941+
* @param $field
866942
*
867943
* @return array|array[]|object|object[]
868944
* @author : 713uk13m <dev@nguyenanhung.com>
869945
* @copyright: 713uk13m <dev@nguyenanhung.com>
870-
* @time : 08/16/2021 30:03
946+
* @time : 16/02/2023 19:08
871947
*/
872948
public function get_all_asc($field = '*')
873949
{
@@ -878,6 +954,25 @@ public function get_all_asc($field = '*')
878954
return $this->db->get()->result();
879955
}
880956

957+
/**
958+
* Function get_all_desc
959+
*
960+
* @param $field
961+
*
962+
* @return array|array[]|object|object[]
963+
* @author : 713uk13m <dev@nguyenanhung.com>
964+
* @copyright: 713uk13m <dev@nguyenanhung.com>
965+
* @time : 16/02/2023 19:03
966+
*/
967+
public function get_all_desc($field = '*')
968+
{
969+
$this->db->select($field);
970+
$this->db->from($this->tableName);
971+
$this->db->order_by($field, 'DESC');
972+
973+
return $this->db->get()->result();
974+
}
975+
881976
/**
882977
* Function count_all
883978
*

0 commit comments

Comments
 (0)