From 37a245c94a4ae4380cc40e12c9aa17f8fd9a1219 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Sat, 18 May 2024 23:06:11 +0700 Subject: [PATCH] add Function getEnum in ORM --- system/orm.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/orm.php b/system/orm.php index 2228d833..46fee905 100644 --- a/system/orm.php +++ b/system/orm.php @@ -939,6 +939,8 @@ class ORM implements ArrayAccess return $this->_add_result_column($column, $alias); } + ## ibnux add function + /** * Add a column to the list of columns returned by the SELECT * query. This defaults to '*'. The second optional argument is @@ -959,6 +961,14 @@ class ORM implements ArrayAccess return $this; } + public function getEnum($column){ + $result = $this->raw_query("SHOW COLUMNS FROM ".$this->_table_name." WHERE Field = '$column'")->findArray(); + preg_match("/^enum\(\'(.*)\'\)$/", $result[0]['Type'], $matches); + return explode("','", $matches[1]); + } + + ## END ibnux add function + /** * Add an unquoted expression to the list of columns returned * by the SELECT query. The second optional argument is