From bf677f717e0713fd0c658e6a5dd3d19a27bae57a Mon Sep 17 00:00:00 2001 From: bison-paolo Date: Wed, 15 Feb 2017 12:50:50 +0100 Subject: [PATCH] Added method addForm to DB_Model --- application/core/DB_Model.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 4a7e561d8..db6e11408 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -429,6 +429,29 @@ class DB_Model extends FHC_Model return success(true); } + /** --------------------------------------------------------------- + * Add a table in the from clause + * + * @return void + */ + public function addFrom($table, $alias = null) + { + $tmpTable = trim($table); + + // Check parameters + if (empty($tmpTable)) + return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + + if (!empty($alias)) + { + $tmpTable .= ' AS ' . $alias; + } + + $this->db->from($tmpTable); + + return success(true); + } + /** --------------------------------------------------------------- * Reset the query builder state *