Saturday, February 6th, 2010 (updated 3 Mar ’10)

Documentation for Insert Entries v1.1.1

Username

Password

Forgot your password?

Register

Elsewhere...

More and more of OpinionJournal goes behind the paywall. Personally I think it’s the right move, because what’s there to lose? If we won’t pay, the business was over anyway. And my bet is we will.

Macworld Expo 2010 Best of Show.

On chatroulette.com.

Russell Beattie: What we really wanted was a MacPad not an iPad.

Sikuli, ingenious GUI scripting. Definitely going to try it.

This video of a tablet mockup makes me horny at last for a tablet computer. I’m excited for tomorrow’s Apple announcement. Guess I’ll be standing in line to buy one as well.

A Little Less Conversation, says Joel Spolsy.

Fake Steve Jobs pens the most insightful piece I’ve read on Google’s complaints vis-a-vis China.

Hypercritical by John Siracusa, or, The Tao of Editing.

A test of input device speed for a 221-word passage.

Insert Entries lets you to easily add rows to in any database table — whether to ExpressionEngine’s database or to any database to which you have administrator access.

Compatibility

The plugin works on both EE v1.x and v2.x.

Installation

For EE v1.x, place the pi.insert_entries.php file in the /plugins directory.

For EE v1.x, create in the /third_party directory a directory /insert_entries, then place the pi.insert_entries.php in there.

Parameters

Required parameters

table

The required table parameter tells the plugin into which database table to insert.

debug

The default value for the debug parameter is “yes”. This is a safety measure to avoid inadvertently adding data wrongly. When debug is on, the plugin does not do the insert. Instead, the SQL query and any error messages are displayed within a div of class “insert-entries-message”. To activate the plugin, set debug to “no”.

Optional parameters

database

The database parameter is required only if inserting into a table on an external database. In this scenario the hostname, password and username parameters are also required.

hostname

The hostname parameter is required only if inserting into a table on an external database. In this scenario the database, password and username parameters are also required.

parse

The parse parameter is common for all plugins. Setting its value to “inward” allows the plugin to contain another plugin.

password

The password parameter is required only if inserting into a table on an external database. In this scenario the hostname, database and username parameters are also required.

username

The username parameter is required only if inserting into a table on an external database. In this scenario the hostname, database and password parameters are also required.

Variables

insert:[column_name]

The only variables used by the plugin are the names of the columns with values to insert, preceded by “insert:”.

Examples

To insert a row into two tables in the current ExpressionEngine database:

{exp:insert_entries table="exp_weblog_titles" debug="n"}
{insert
:title}My New Entry{/insert:title}
{insert
:url_title}my-new-entry{/insert:url_title}
{
/exp:insert_entries}

{exp
:insert_entries table="exp_weblog_data" debug="n"}
{insert
:field_id_1}My New Content{/insert:field_id_1}
{insert
:field_ft_1}none{/insert:field_ft_1}
{
/exp:insert_entries} 

Note that adding weblog entries requires knowing the actual column name of the field being added. All weblog fields are in the format “field_id_[xx]”, such as field_id_40. One easy way to find this value is to look at the query string of the URL when editing a field. At the end of the URL’s query string is the field_id — the value here is the number we seek.

To insert a row into a table on an external database:

{exp:insert_entries 
    hostname
="www.cia.gov" 
    
database="agencies" 
    
username="felix_leiter" 
    
password="alimentary" 
    
table="field_agents" 
    
debug="n"
}
{insert
:name}James Bond{/insert:name}
{insert
:family_motto}The world is not enough.{/insert:family_motto}
{insert
:weapon}Beretta 418{/insert:weapon}
{
/exp:insert_entries} 

Changelog

v1.1.1 (2010 Mar 3)

  • Fixed bug so that plugin can be used more than once on a template in EEv2

v1.1 (2010 Feb 8)

  • made compatible with both EEv1.x and EEv2.x

Post a comment

Name:

Email:

Location:

URL:

Your comment:

Remember my personal information
Notify me of follow-up comments?

Please enter the word you see in the image below: