how to call a model class const in a controller class?

i am new to ci, so probably a dumb question:
if i use class const in a model,

class Xmodel extends Model {
const X1 = 1;

Then how do i use it in a controller, for example? Is Xmodel::X1 available to use after loading the model?

or i should just use plain variable?


It depends, if the value will not change use a constant.

If the value will change use a veriable.

// for a variable, then you can have a function return it.
var x1 = 1;

// For a constant
DEFINE('X1', 1);

// either way you can just return the value.

class Xmodel extends Model {
  const X1 = 1;


A model is a set of data,and a view is a GUI component that can present a visual representation of the model to the user.A design pattern is a recurring solution that simplifies the design process. The thoughtful study of design patterns allows a developer to learn from the pioneering work of others.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.