コード例 #1
0
ファイル: example.php プロジェクト: killsaw/bitmapper
function generate_data($entries = 10000)
{
    $i = 0;
    $buffer = '';
    for ($i = 0; $i < $entries; $i++) {
        $userprefs = new UserPrefs();
        $userprefs->is_admin = rand(0, 1);
        $userprefs->is_banned = rand(0, 1);
        $userprefs->agreed_to_terms = rand(0, 1);
        $userprefs->gold_member = rand(0, 1);
        $userprefs->pref_autologin = rand(0, 1);
        $userprefs->pref_show_ads = rand(0, 1);
        $userprefs->pref_newsletter = rand(0, 1);
        $userprefs->pref_chat_enabled = rand(0, 1);
        $buffer .= $userprefs->toBinary();
    }
    if ($fp = fopen(__DIR__ . '/example.data', 'wb+')) {
        fwrite($fp, $buffer);
        fclose($fp);
    }
    unset($buffer);
}
コード例 #2
0
 /**
  * Obtiene una entrada del diccionario.
  * @param string $userId id del usuario.
  * @param string $dictName nombre del diccionario de dónde obtener la entrada.
  * @param string $entryId Id de la entrada a eliminar del diccionario.
  * @param bool $found (out) (optional) Si es colocada, el valor de ésta será true si la entrada es encontrada.
  * @return array
  */
 public static function GetEntry($userId, $dictName, $entryId, &$found = false)
 {
     $dictionary = UserPrefs::GetDictionary($userId, $dictName);
     $found = isset($dictionary[$entryId]);
     return $found ? $dictionary[$entryId] : null;
 }
コード例 #3
0
 /**
  * Tests UserPrefs->getPrefs()
  */
 public function testGetPrefsReturnNull()
 {
     $key = 'non_existing_key';
     $this->assertNull($this->UserPrefs->getPref($key));
 }