Welcome Guest, Not a member yet? Register   Sign In
Share Variables
#1

[eluser]reset[/eluser]
Hello,

I would like to create some varibles which content the name of the tables in my database, for use that whit all models. Example

Code:
<?php
//file 1 witch the config of table names
//...
$config['table']['users'] = 'tbl_users';
//...

//file 2 Class model_1
Class model_1 extends Model{
//...

function get1(){
//...
$this->db->get($config['table']['users']);
//...
}
//...
}

//file 3 Class model_2
Class model_2 extends Model{
//...

function get2(){
//...
$this->db->get($config['table']['users']);
//...
}
//...
}
?>

My english is bad, I hope I have understood you.
#2

[eluser]_asdf[/eluser]
if its coming from an external file, you'll need to:
Code:
$this->config->load('yourConfigFile');
or autoload it.

if you just need to access the config variable, use
Code:
$this->config->item('array hash/index');
[url="http://ellislab.com/codeigniter/user-guide/libraries/config.html"]see the user-guide[/url].




Theme © iAndrew 2016 - Forum software by © MyBB