.

Tristate
[DB]

Classes

class   DBFieldTristate
  An tristate enum field. More...
class   Tristate
  Provides tristate logic. More...

Functions

  tristate_load_translations ($languages)
  Tristate translations.

Detailed Description

Since:
0.5.1

A tristate DB field, allowing a user choice of YES, NO, and UNKNOWN.

While a tristate also can be achieved unsing a boolean field together with a NULL value, the Tristate DB field allows easier user input, since NULL is difficult to represent using default boolean user input widgets.

Usage

The tristate field is basically an Enum field, and can be used like this.

Use class DBFieldTristate in table declaration:

   ...
   new DBFieldTristate('fieldname', Tristate::UNKNOWN, DBField::NOT_NULL),
   ...

The Tristate class defines the three possible tristate values and offers helper functions.


Function Documentation

tristate_load_translations ( languages  ) 

Tristate translations.

Since:
0.5.1
Author:
Gerd Riesselmann

Definition at line 10 of file tristate.translations.php.

00010                                                 {
00011         return array(
00012                 Tristate::YES => array(
00013                         'en' => 'Yes',
00014                         'de' => 'Ja'
00015                 ),
00016                 Tristate::NO => array(
00017                         'en' => 'No',
00018                         'de' => 'Nein'
00019                 ),
00020                 Tristate::UNKOWN => array(
00021                         'en' => 'Unknown',
00022                         'de' => 'Unbekannt'
00023                 ),
00024         );
00025 }