Link | Bramus_ParamsTableMatch |
Author | Bram Van Damme |
Category | Custom Tag |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 23 Jan 2006 |
Updated | 23 Jan 2006 |
More by this author... |
In some situations, one has to split data over multiple tables in a database. But most likely, one wants to have 1 form edit all the info related to that item. However, when passing the Action_Params to an inline, it won't work, since multiple tables are needed and a single table does not contain all fields passed through the Action_Params. This function creates a new set of Params to match to a given table its fields.
Of course the propper access rights to the (mysql) database should be in place. Execution of SQL statements should also be allowed for the user.
[Var: 'nParams' = Bramus_ParamsTableMatch('username','pass','database','table',Action_Params)] [Inline: -Username='username', -Password='pass', -Database='database', -Table='table', -KeyField='id', -KeyValue=(Action_Param:'id'), $nParams, -Update]
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
Define_Tag: 'ParamsTableMatch', -NameSpace = 'Bramus_', -Description = 'Manipulates a set of params (like Action_Params) to contain only the params which match to the fields of a given table', -Priority = 'replace', -Required = 'username', -Required = 'password', -Required = 'database', -Required = 'table', -Required = 'params', -Type = 'Array'; Local: 'sql' = 'DESCRIBE ' + #table; // The Query to get the fields Local: 'fieldset' = Array; // The fieldset of the table's fields Local: 'retparams' = Array; // The params to return Inline: -Username = #username, -Password = #password, -Database = #database, -MaxRecords = 'All', -SQL = #sql; Records; #fieldset->Insert(Field: 'Field'); /Records; /Inline; Iterate: #params, (Local: 'param'); If: #fieldset->Contains(#param->First); #retparams->Insert(Pair((#param->First)=(#param->Second))); /If; /Iterate; Return: #retparams; /Define_Tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft