Welcome Guest, Not a member yet? Register   Sign In
how to call a model class const in a controller class?
#1

[eluser]Unknown[/eluser]
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?

Thanks...
#2

[eluser]InsiteFX[/eluser]
It depends, if the value will not change use a constant.

If the value will change use a veriable.

Code:
// 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;
  ....
}

InsiteFX
#3

[eluser]jedc53[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB