Welcome Guest, Not a member yet? Register   Sign In
Database-based configuration library/model?
#4

[eluser]Mushex Antaranian[/eluser]
I'm using model for it, like OpenBlog.. hope it will help you

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Db_settings_model extends Model
{
    public $table = 'settings';
    // Constructor
    public function __construct()
    {
        parent::Model();
    }

    function get_settings($name = '')
    {
        $this->db->select('name, value');
        if ($name != '') {
            $this->db->where('name', $name);
        }
        $query = $this->db->get($this->table);
        if ($query->num_rows() > 0)
        {
            $result = $query->result_array();
            foreach ($result as $row)
            {
                $settings[$row['name']] = $row['value'];
            }
            return $settings;
        }
    }

    function set_settings($settings = array())
    {
           foreach ($settings as $name => $value) {
            $this->db->set('value', $value);
            $this->db->where('name', $name);
            $this->db->update($this->table);;
        }
    }
?>

If any questions, feel free to email me jesirobendebua@gmail )


Messages In This Thread
Database-based configuration library/model? - by El Forum - 04-24-2009, 06:26 AM
Database-based configuration library/model? - by El Forum - 04-24-2009, 11:55 AM
Database-based configuration library/model? - by El Forum - 04-24-2009, 01:52 PM
Database-based configuration library/model? - by El Forum - 04-24-2009, 02:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB