Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
en:create:databank [08.07.2016 20:11] – [Import Data] ncruzen:create:databank [26.11.2020 20:59] – [Example 4: Relay A Priori Data] sophia.schauer
Line 199: Line 199:
 // now show the question  // now show the question 
 question('ST01'); question('ST01');
 +</code>
 +
 +===== Example 5: Complete Data =====
 +
 +To add an entry to the database for content during the interview, it must be read out, added and then written again.
 +
 +For example, under the key "FS-<Serial number>" a-priori data was stored (3 entries per person, i.e. indices 0 to 2). In survey wave 1 a product preference from question PP01 is now to be added as fourth date (index 3). The following PHP code could then be placed on the page __after__ the page with PP01 (see notes on ''[[:en:create:functions:value]]'')
 +
 +<code php>
 +$key = 'FS-'.caseSerial();
 +// Reading data
 +$data = dbGet($key);
 +if ($data === false) {
 +  // No data found - maybe show warning
 +  $data = array(-8, -8, -8);  // ... and initialize the data element
 +}
 +// Add the answer from PP01
 +$data[3] = value('PP01');
 +// save entry again
 +$data = dbSet($key, $data);
 </code> </code>
en/create/databank.txt · Last modified: 21.04.2024 20:21 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki