To create a Custom Data Plugin or an Extension for Injader, you'll need to understand how to create SQL statements in Injader.
Custom Data Plugins can just use SQL and HTML to retrieve and format the data you wish to use. Extensions need to use PHP instead. Here's an example:
$CMS->Query("UPDATE {IFW_TBL_CONTENT} SET title = 'New Title' WHERE id = 1", basename(__FILE__), __LINE__);
This code uses the Query method to run a SQL statement. This method should be used for SQL that does not need to return a result. However, it is possible to retrieve a new row ID for an INSERT statement. For instance:
$intNewRowID = $CMS->Query("INSERT INTO {IFW_TBL_FORM_RECIPIENTS}(name, email, recipient_order) VALUES('Mr John Smith', 'john@smith.com', 1)", basename(__FILE__), __LINE__);
This will create a new form recipient with the name Mr John Smith, email address john@smith.com, and set the order to 1. (Form recipients are displayed in numerical order.) $intNewRowID will then contain the ID of the form recipient you just added to the database.
If you wish to return some results, use ResultQuery instad.
$arrData = $CMS->ResultQuery("SELECT * FROM {IFW_TBL_CONTENT} WHERE id IN (1,2,3,4,5)", basename(__FILE__), __LINE__);
Assuming that articles 1 to 5 exist, this will store the data for each of the selected articles in the $arrData array. You can then access the array like this:
for ($i=0; $i<count($arrData); $i++) {
$intArticleID = $arrData[$i]['id'];
...
}
The field names are the same as the fields on the table you have selected.
The Query and ResultQuery methods accept three parameters. The first is the SQL you wish to execute. The second and third parameters are only used if the query fails, as they provide information that is vital for debugging purposes. You are strongly recommended to use the above examples in the format provided, only altering the SQL for your own purposes.
You may have noticed that the table name is referred to as {IFW_TBL_CONTENT} rather than maj_content. This is to ensure that the code continues to work as it should if you use a different prefix for your table names. {IFW_TBL_CONTENT} is replaced with the name of the table, prefix and all, prior to the execution of the SQL query.
The complete list of table constants can be found in sys/includes/ifw/IQuery_Tables.php.
Navigation: start