[Bramus_ParamsTableMatch]

Description

Link: [Bramus_ParamsTableMatch]
Author: Bram Van Damme
Category: Custom Tag
Version: 8.x
License:
Posted: Jan. 23, 2006
Updated: Jan. 23, 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.

Parameters

-database string, required Database name
-params array, required Set of params to manipulate
-password string, required Database password
-table string, required Database table to match the params to
-username string, required Database username

Sample Usage

[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]
						

Source Code

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net