• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A simple config class issue

[eluser]Dagobert Renouf[/eluser]
Hello guys,

I'm currently optimizing my first app code (a bit messy 'round here) and I'm trying to write config files to store MY specific data.

I created a file named "my_db_parameters" in the system/config folder, and I autoload it.

here's the file's code :
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['my_db_tables'] = array('blog' => 'blog_entries');


when I try to call it in my blog model like this :

I have an error
Quote:Fatal error: Call to undefined method CI_Config::my_db_tables()

I don't get why this doesn't work, help me out BROTHERS.

$tables = $this->config->item('my_db_tables');
$blog_table = $tables['blog'];
If you want direct access you can do
$config['db_table_blog'] = 'blog_entries';

[eluser]Dagobert Renouf[/eluser]
thank you xwero it works fine.

However I would like to ask - what's the best way to achieve my goal (storing my specific data)?
The second method seems better to me but there are so many ways to do this, what do you guys advice ?

less code is in most cases the best way to go.

[eluser]Dagobert Renouf[/eluser]

nothing more to say.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.