[[dbSet()]]
 

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:create:functions:dbset [24.01.2015 14:17] – [dbSet()] alexander.ritteren:create:functions:dbset [09.03.2022 11:02] (current) – [dbSet()] ruth.noppeney
Line 8: Line 8:
 ''void **dbSet**(string //key//, false|string|array //data//)'' ''void **dbSet**(string //key//, false|string|array //data//)''
  
-  * //key//\\ Database key which will be created, updated, or deleted+  * //key//\\ Database key which will be created, updated, or deleted. The database key must contain between 2 und 63 characters. Umlauts may require more than one character. 
   * //data//\\   * //data//\\
     * ''false'' -- Database entry is deleted, if it exists     * ''false'' -- Database entry is deleted, if it exists
Line 31: Line 31:
 ===== Example 2 ===== ===== Example 2 =====
  
-The following PHP code checks if an entry exists with the transmitted reference ([[:en:survey:url|URL to the Questionnaire]]). The reference encodes a company. The participant is only allowed to continue with the survey when a max. of 10 people from the company have participated up to now.+The following PHP code checks whether an entry with the submitted reference ([[:en:survey:url|URL to the Questionnaire]]) exists. The reference encodes a company. The participant is only allowed to continue with the survey if a max. of 10 people from the company have participated so far.
  
 <code php> <code php>
Line 51: Line 51:
 </code> </code>
  
-The counter is incremented only from the last page in the questionnaire -- otherwise, it would count incompleted ones as well. +The counter is incremented on the last pages in the questionnaire onlt -- otherwise, it would count incomplete questionnaires as well. 
  
  
 <code php> <code php>
-// Counter increments one +// Counter increments by one 
-if (isset($counted)) {+if (!isset($counted)) {
   $info = dbGet(reference());   $info = dbGet(reference());
   $info[1]++;   $info[1]++;
   dbSet(reference(), $info);   dbSet(reference(), $info);
-  // Together with isset() it ensures it only counts once+  // Together with isset() it ensures it is counted once only
   $counted = true;   $counted = true;
   registerVariable('counted');   registerVariable('counted');
Line 69: Line 69:
 ===== Example 3 ===== ===== Example 3 =====
  
-Perhaps the entry for the reference from example 2 should also just be deleted when the first participant from the company has filled out the questionnaire. To do so, the second PHP code is modified as follows.+Perhaps the reference entry from example 2 should just be deleted when the first participant from the company has filled out the questionnaire. To do so, the second PHP code is modified as follows.
  
 <code php> <code php>
 dbSet(reference(), false); dbSet(reference(), false);
 </code> </code>
en/create/functions/dbset.txt · Last modified: 09.03.2022 11:02 by ruth.noppeney
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki