Database Configuration
revIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). The config file is located at:
application/config/database.irev
The config settings are stored in a multi-dimensional array with this prototype:
put "localhost" into sDB["default"]["hostname"]
put "root" into sDB["default"]["username"]
put "" into sDB["default"]["password"]
put "databaseName" into sDB["default"]["database"]
put "mysql" into sDB["default"]["dbdriver"]
put "" into sDB["default"]["dbprefix"]
put TRUE into sDB["default"]["pconnect"] -- currently not implemented
put FALSE into sDB["default"]["dbdebug"]
put FALSE into sDB["default"]["cacheon"]
put "" into sDB["default"]["cachedir"]
put "utf8" into sDB["default"]["charset"]
put "utf8_general_ci" into sDB["default"]["dbcollat"]
put TRUE into sDB["default"]["cacheautodel"]
The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store multiple sets of connection values. If, for example, you run multiple environments (development, production, test, etc.) under a single installation, you can set up a connection group for each, then switch between groups as needed. For example, to set up a "test" environment you would do this:
put "localhost" into sDB["test"]["hostname"]
put "root" into sDB["test"]["username"]
put "" into sDB["test"]["password"]
put "databaseName" into sDB["test"]["database"]
put "mysql" into sDB["test"]["dbdriver"]
put "" into sDB["test"]["dbprefix"]
put TRUE into sDB["test"]["pconnect"] -- currently not implemented
put FALSE into sDB["test"]["dbdebug"]
put FALSE into sDB["test"]["cacheon"]
put "" into sDB["test"]["cachedir"]
put "utf8" into sDB["test"]["charset"]
put "utf8_general_ci" into sDB["test"]["dbcollat"]
put TRUE into sDB["test"]["cacheautodel"]
Then, to globally tell the system to use that group you would set this variable located in the config file:
put "test" into sActiveGroup
Note: The name "test" is arbitrary. It can be anything you want. By default we've used the word "default" for the primary connection, but it too can be renamed to something more relevant to your project.
Active Record
The Active Record Library is globally enabled or disabled by setting the gActiveRecord variable in the database configuration file to TRUE/FALSE (boolean). If you are not using the active record library, setting it to FALSE will utilize fewer resources when the database libraries are initialized.
put TRUE into gActiveRecord
Note: that some revIgniter libraries such as Sessions require Active Records be enabled to access certain functionality.
Explanation of Values:
- hostname - The hostname of your database server. Often this is "localhost".
- username - The username used to connect to the database.
- password - The password used to connect to the database.
- database - The name of the database you want to connect to.
- dbdriver - The database type. ie: mysql, postgre, etc. Must be specified in lower case.
- dbprefix - An optional table prefix which will added to the table name when running Active Record queries. This permits multiple revIgniter installations to share one database.
- pconnect - TRUE/FALSE (boolean) - Whether to use a persistent connection (currently not implemented).
- dbdebug - TRUE/FALSE (boolean) - Whether database errors should be displayed.
- cacheon - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also Database Caching Library.
- cachedir - The absolute server path to your database query cache directory.
- charset - The character set used in communicating with the database.
- dbcollat - The character collation used in communicating with the database.
- port - The database port number. Currently only used with the Postgres driver. To use this value you have to add a line to the database config array.
put 5432 into sDB["default"]["port"]
Note: Depending on what database platform you are using (MySQL, Postgres, etc.) not all values will be needed. For example, when using SQLite you will not need to supply a username or password, and the database name will be the path to your database file. The information above assumes you are using MySQL.