AddFields Context
   
 

[AddFields db=…]...WebDNA...[/AddFields]


The [AddFields] context adds new fields to an existing WebDNA database.


First, lets use the following code to create a new test database and run a simple search on the new database.


[closedatabase db=addfields_test.db]

[writefile file=addfields_test.db]ID,NAME
"1","Scott"
"2","Rusty"
"3","David"
"4","Daniel"
"5","Dustin"
[/writefile]

[search db=addfields_test.db&neIDdata=[blank]&rank=off]
[founditems]
[ID] - [NAME]

[/founditems]
[/search]

 

Results:


1 - Scott
2 - Rusty
3 - David
4 - Daniel
5 - Dustin

Now, lets use the [AddFields] context to add EMAIL and PHONE fields to the 'addfields_test.db' database, initializing the new field value with some arbitrary data. We will again perform a simple search on the same database to confirm that the new fields, and field data, have been added.

We use the following WebDNA code:


[AddFields db=addfields_test.db]EMAIL=us.here.com&PHONE=123-1235[/AddFields]

[search db=addfields_test.db&neIDdata=[blank]&rank=off]
[founditems]
[ID] - [NAME] - [EMAIL] - [PHONE]

[/founditems]
[/search]

Results:


1 - Scott - us.here.com - 123-1235
2 - Rusty - us.here.com - 123-1235
3 - David - us.here.com - 123-1235
4 - Daniel - us.here.com - 123-1235
5 - Dustin - us.here.com - 123-1235

Note that the [AddFields] context will not add fieldnames that already exist in the target database.

   

User Contributed Notes
AddFields  

Donovan Brooke - dbrooke@ehg.net 
03/25/2003 at 09:50:18
Cool new tag.  Can you set the value to blank? (ie. "EMAIL=")?

Donovan

Bill DeVaul  
05/23/2003 at 08:36:27
Can you use the autonumber feature with a new field?

Tim Robinson - tim@idfk.com.au 
07/02/2003 at 19:32:50
You have to specify a value for the fields for this to work. If you want a blank value, use this:
[AddFields db=test.db]field1=&field2=[/AddFields]

Copyright © 2008 WebDNA Software Corporation, Inc.