CodeIgniter Forums
(SOLVED)Calling a const field of a Model from Controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: (SOLVED)Calling a const field of a Model from Controller? (/showthread.php?tid=33430)



(SOLVED)Calling a const field of a Model from Controller? - El Forum - 08-25-2010

[eluser]juanvillegas[/eluser]
I don't know if this would be the ideal CI way, but im making some tests here!
Let's say you've got model

Code:
class Test_model extends Model {

const MYVALUE='somevalue';


<...>
}

and CONTROLLER
Code:
class Register extends Controller {

function __construct() {
$this->load->model('Test_model','test');
}
<...>
}

How would i normally access const MYVALUE from the controller? I have tried a few but couldnt get it working.
Thanks!


(SOLVED)Calling a const field of a Model from Controller? - El Forum - 08-25-2010

[eluser]danmontgomery[/eluser]
Code:
Test_model::MYVALUE

http://www.php.net/manual/en/language.oop5.constants.php


(SOLVED)Calling a const field of a Model from Controller? - El Forum - 08-25-2010

[eluser]juanvillegas[/eluser]
Exactly, thanks a lot!