revIgniter's Scaffolding feature provides a fast and very convenient way to add, edit, or delete information in your database during development.
Very important: Scaffolding is intended for development use only. It provides very little security other than a "secret" word, so anyone who has access to your revIgniter site can potentially edit or delete your information. If you use Scaffolding make sure you disable it immediately after you are through using it. DO NOT leave it enabled on a live site. And please, set a secret word before you use it.
Why would someone use scaffolding?
Here's a typical scenario: You create a new database table during development and you'd like a quick way to insert some data into it to work with. Without Scaffolding your choices are either to write some inserts using the command line or to use a database management tool like phpMyAdmin. With revIgniter's Scaffolding feature you can quickly add some data using its browser interface. And when you are through using the data you can easily delete it.
Setting a Secret Word
Before enabling Scaffolding please take a moment to set a secret word. This word, when encountered in your URL, will launch the Scaffolding interface, so please pick something obscure that no one is likely to guess.
To set a secret word, open your application/config/routes.lc file and look for this item:
put "" into gRoute["scaffoldingTrigger"]
Once you've found it add your own unique word.
Note: The Scaffolding word can not start with an underscore.
Note: The information on this page assumes you already know how controllers work, and that you have a working one available. It also assumes you have configured revIgniter to auto-connect to your database. If not, the information here won't be very relevant, so you are encouraged to go through those sections first.
To enable Scaffolding you will initialize it in your controller with just one line of code like this:
<?lc # PUT YOUR HANDLER NAMES INTO THE GLOBAL gControllerHandlers AS A COMMA SEPARATED LIST put "blog,index" into gControllerHandlers command blog rigLoadScaffolding "tableName" end blog command index -- Your code here … get rigLoadView("blogview.lc") end index --| END OF blog.lc --| Location: ./application/controllers/blog.lc ----------------------------------------------------------------------
Where tableName is the name of the table (table, not database) you wish to work with.
Note: The rigLoadScaffolding handler must be called before anything else. So, in the example above rigLoadScaffolding is in the blog handler as it is run before the index handler.
Once you've initialized Scaffolding, you will access it with this URL prototype:
For example, using a controller named Blog, and abracadabra as the secret word, you would access Scaffolding like this:
The Scaffolding interface should be self-explanatory. You can add, edit or delete records.
To change the number of records displayed open your application/config/config.lc file and look for this item:
put 10 into gConfig["scaffNumRecords"]
A Final Note:
The Scaffolding feature will only work with tables that contain a primary key, as this information is needed to perform the various database functions.