dbparam Allows to store custom application params in the DB

  1. Documentation
  2. Change Log

This extension provides a handy way to store and use application parameters such as caching time for components, site admin email, or other things. It is extremely useful when you need to provide interface for editing of these parameters. The out-of-box Yii distribution allows to use only configuration file, which is not perfect way to do it (yet much faster). Current extension allows you to configure parameters.

Resources

Documentation

Requirements
  • Yii 1.0 or above
  • Any supported DBMS (tested only with MySQL, but should work on others as well)
Installation
  • Extract the release file under protected/extensions
  • If your DBMS doesn't support BLOB, LONGBLOB etc type, you should:
    • Edit method createParamsTable to create the table type you need
    • Edit lines 302, 310 and change PDO::PARAM_LOB to the constant you need
Usage

Set up component in the application config:

'par'=>array(
	'class' => 'application.extensions.dbparam.XDbParam',
	'connectionID' => 'db',//id of the connection component, just the same as with CDbCache
//	'preload' => 'test,test2', //comma-separated string or array of params to be loaded anyway. Other params are loaded only when requested.
//	'autoLoad' => true,//loads all attributes when initializing
//	'caseSensitive' => true, //setting to true makes all parameters case sensitive
	),

Use the component:

Yii::app()->par->test = '1234';//set parameter. If it is not present, it will be created
echo Yii::app()->par->test;//output parameter. If it is not present, exception is thrown

//load several parameters in one query. Useful if you're going to use them in the next lines
Yii::app()->par->load(array('test', 'test2'));
//OR
Yii::app()->par->load('test,test2');
//OR
Yii::app()->par->load();//loads all attributes

//delete the specified parameters or all of them if none specified
Yii::app()->par->purge('test,test2');//delete test and test 2
//OR
Yii::app()->par->purge(array('test', 'test3'));//delete test and test 3
//OR
Yii::app()->par->purge();//delete ALL parameters!

Change Log

March 4, 2009
  • Initial release.
    March 5, 2009
  • Version 2.0:
  • Added autoloading of all parameters (autoLoad config option)
  • Added reloading of all parameters ($component->load() - calling without params loads all parameters)
  • Rewrote all get/set code to make it work faster
  • Changed hierarchy, it is now extended from CAttributesCollection and implements IApplicationComponent
8 0
6 followers
1 164 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Tags:
Developed by: KJedi
Created on: Mar 4, 2009
Last updated: 15 years ago

Downloads

show all