Lasso Soft Inc. > Home

[Bramus_ParamsTableMatch]

LinkBramus_ParamsTableMatch
AuthorBram Van Damme
CategoryCustom Tag
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted23 Jan 2006
Updated23 Jan 2006
More by this author...

Description

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.

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.

	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

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft