Welcome Guest, Not a member yet? Register   Sign In
Best way to set global vars/constants?
#1

[eluser]Medikal[/eluser]
Hey guys, just curious. I have a ton of things I would like to set to global constants I can use anywhere just for ease of the use in the future in case I change anything. My best example is I'm constantly using $this->db->from("articles") or something of the sort, I'd rather have a constant defined as ARTICLES_TABLE and always refer to it as that so if the table name changed I could change it in one file for every query, among other things.

Cheers.
#2

[eluser]Pschilly[/eluser]
Constants file in the /application/config folder
#3

[eluser]markup2go[/eluser]
Well you can't use models in the application/config/constants.php file... but you can create a base controller which contains the global variables and then extend it from each new controller you create.

http://codeigniter.com/wiki/MY_Controlle...ontroller/




Theme © iAndrew 2016 - Forum software by © MyBB