Welcome Guest, Not a member yet? Register   Sign In
Assigning Query (Read) Results to Variables
#11

[eluser]nydeveloper[/eluser]
Is there something additional that needs to be done to make these variables available to other functions within the same model?

I tried the following, but received an undefined variable error:

Code:
function variable_test()
    {

echo $math_grade . '<br />';

    }
#12

[eluser]Bhashkar Yadav[/eluser]
try like this

Code:
class Simple_model extends CI_Model
{
    public $var = '';
    public function your_method1() {
        $this->var = $some_value;
    }
    public function your_method2() {
        echo $this->var;
    }
}

hope this would help you.
#13

[eluser]nydeveloper[/eluser]
Quote:try like this

Code:
class Simple_model extends CI_Model
{
    public $var = '';
    public function your_method1() {
        $this->var = $some_value;
    }
    public function your_method2() {
        echo $this->var;
    }
}
hope this would help you.

I've tried a few variations of the above, but am having no luck. The variable(s) in question are still not being recognized by any functions other than the one which extracts data from the array and assigns it to the respective variable(s). I still receive the 'undefined variable' error each time when trying to use them in another function within the same model.

Does anyone have any other suggestions on how I can achieve this? Thanks.

#14

[eluser]CroNiX[/eluser]
I think you need to learn more basic PHP before trying to get into OOP or CodeIgniter. Not trying to be mean, but this is basic PHP stuff.
#15

[eluser]InsiteFX[/eluser]
You state that the variables in question are not being recognized but you do not show the code here that is giving you the problem! Show the code with the problem...




Theme © iAndrew 2016 - Forum software by © MyBB