Update
h2(#update-function). Parameters for
exp:external_entries:update
h3. Required parameters
h4. debug=
The default value for the
debug parameter is "yes". This is a safety measure to avoid inadvertently changing data wrongly. When debug is on, the plugin does not do the update. Instead, the SQL query and any error messages are displayed within a div of class "update-entries-message". To activate the plugin, set
debug to "no", otherwise no update will be performed.
h4. table=
The required
table parameter tells the plugin which database table to update.
h3. Optional parameters
h4. allow_php=
Lets the plugin's values contain PHP. Values are "y" or "n"; default is "n" (for security). Set to "y" for characters such as greater than/less than signs to not be converted to entities. PHP must be set in the template to the "input" setting.
h4. connection=
Set to "persistent" if using an external database and EE's database settings are for non-persistent connections.
h4. database=
The
database parameter is required only if updating a table on an external database. In this scenario the hostname, password and username parameters are also required.
h4. hostname=
The
hostname parameter is required only if updating a table on an external database. In this scenario the database, password and username parameters are also required.
h4. limit=
If the
limit parameter is not set, the default value is "1". This is a safety measure to minimize the damage done by any inadvertent data changes.
h4. parse=
The
parse parameter is common for all plugins. Setting its value to "inward" allows the plugin to contain another plugin.
h4. password=
The
password parameter is required only if updating a table on an external database. In this scenario the database, hostname and username parameters are also required.
h4. search:[column_name]=
The
search:[column_name] parameter limits the plugin to update only those rows in the table where the value of the specified column is equal to the value entered. To search for multiple results within one column, separate each value with a pipe, ie,
search:my_column="my text|my other text".
Any number of search:[column_name] parameters may be used; they are connected by an "and" boolean operator. These parameters form the part of the SQL query following "WHERE".
h4. username=
The
username parameter is required only if updating a table on an external database. In this scenario the database, hostname and password parameters are also required.
h2. Variables for
exp:external_entries:update
h4. update:[column_name]
The only variables used by the plugin are the names of the columns to be updated, preceded by "update:".
h2. Examples for
exp:external_entries:update
To update a table on the current ExpressionEngine database:
{exp:external_entries:update table="exp_channel_titles" search:entry_id="{entry_id}" debug="n"}
{update:status}Purchased{/update:status}
{/exp:external_entries:update}
(To update channel entries fields requires knowing the actual column name of the field being updated. All channel 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 update a table on an external database:
{exp:external_entries:update
hostname="www.cia.gov"
database="agencies"
username="felix_leiter"
password="alimentary"
table="field_agents"
search:agents_id="7"
debug="n"
}
{update:weapon}Walther PPK 7.65mm{/update:weapon}
{/exp:external_entries:update}