public function select($name = null, $default = null)
    {
        if (!$this->db->isInitialized()) {
            return isset($name) ? $default : array();
        }

        $conditions = array();

        $sql = 'SELECT * FROM settings';

        if (isset($name)) {
            $conditions[] = $name;
            $sql .= ' WHERE id=? LIMIT 0,1';
        }

        $settings = array();

        foreach ($this->db->fetchAll($sql, $conditions) as $result) {

            if (!empty($result['serialized'])) {
                $result['value'] = unserialize($result['value']);
            }

            $settings[$result['id']] = $result['value'];
        }

        return isset($name) ? reset($settings) : $settings;
    }
public function select($name = null, $default = null)
    {
        if (!$this->db->isInitialized()) {
            return isset($name) ? $default : array();
        }

        $conditions = array();

        $sql = 'SELECT * FROM settings';

        if (isset($name)) {
            $conditions[] = $name;
            $sql .= ' WHERE id=? LIMIT 0,1';
        }

        $settings = array();

        foreach ($this->db->fetchAll($sql, $conditions) as $result) {

            if (!empty($result['serialized'])) {
                $result['value'] = unserialize($result['value']);
            }

            $settings[$result['id']] = $result['value'];
        }

        return isset($name) ? reset($settings) : $settings;
    }
public function select ( $ name = null , $ default = null ) { if ( ! $ this -> db -> isInitialized ( ) ) { return isset ( $ name ) ? $ default : array ( ) ; } $ conditions = array ( ) ; $ sql = 'SELECT * FROM settings' ; if ( isset ( $ name ) ) { $ conditions [ ] = $ name ; $ sql .= ' WHERE id=? LIMIT 0,1' ; } $ settings = array ( ) ; foreach ( $ this -> db -> fetchAll ( $ sql , $ conditions ) as $ result ) { if ( ! empty ( $ result [ 'serialized' ] ) ) { $ result [ 'value' ] = unserialize ( $ result [ 'value' ] ) ; } $ settings [ $ result [ 'id' ] ] = $ result [ 'value' ] ; } return isset ( $ name ) ? reset ( $ settings ) : $ settings ; }
Select all or a single setting from the database
@param null|string $name
@param mixed $default
@return mixed
Select all or a single setting from the database