Welcome Guest, Not a member yet? Register   Sign In
Loading from Mysql Confings
#5

[eluser]elmne[/eluser]
Since you want to put values from database to global variables so that the values are accessible to all users, look at this post

ellislab.com/forums/viewthread/89488/

Someone there used a workaround.


But if it's per user and not all users, you could use sessions.

----


Try looking at this post where someone used constants instead of globals
Quote:http://stackoverflow.com/questions/25271...l-variable

I ran into a similar problem earlier today. I found that an easier way, rather than globals, was to use constants. You can define a constants file that will load from your index.php file:

Code:
// Include additional constants
$defines_file = 'includes/defines.php';
if (file_exists($defines_file))
{
    require_once($defines_file);
}
Then you can add your constants to the defines.php file:

Code:
define(MY_CONSTANT,'my constant info');
This way they will be available in any file throughout the system either directly: echo MY_CONSTANT; or you can assign them to variables.

I decided this way would be easier for me as I would only have 1 location to go to when/if I needed to change the constants.

More: http://ellislab.com/forums/viewthread/56981/#280205

also look at codeignitor.com/user_guide/libraries/loader.html

you can use this to load your variables as you will find a description on that page that states
Quote:
Code:
$this->load->vars($array)
This function takes an associative array as input and generates variables using the PHP extract function. This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might want to use this function independently is if you would like to set some global variables in the constructor of your controller and have them become available in any view file loaded from any function. You can have multiple calls to this function. The data get cached and merged into one array for conversion to variables.


Messages In This Thread
Loading from Mysql Confings - by El Forum - 06-22-2010, 04:00 PM
Loading from Mysql Confings - by El Forum - 06-24-2010, 07:19 AM
Loading from Mysql Confings - by El Forum - 06-24-2010, 08:26 AM
Loading from Mysql Confings - by El Forum - 06-24-2010, 12:12 PM
Loading from Mysql Confings - by El Forum - 06-24-2010, 05:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB