当前位置: 首页>>代码示例>>PHP>>正文


PHP defaultDB函数代码示例

本文整理汇总了PHP中defaultDB函数的典型用法代码示例。如果您正苦于以下问题:PHP defaultDB函数的具体用法?PHP defaultDB怎么用?PHP defaultDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了defaultDB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_definition

function add_definition($spart, $value)
{
    $w = $GLOBALS["word"];
    $d = DEFINITION(defaultDB(), NULL, $w);
    $d->set_lang("en");
    $d->set_value($value);
    $p = PATH($w, $spart);
    $d->set_path($p);
    $d = $w->add_definition($d);
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:10,代码来源:wordlist.php

示例2: run_template2

function run_template2($word, $t, $arg, $definition)
{
    if (!$ignore) {
        $ignore = [];
    }
    if ($word !== NULL and $definition) {
        $d = DEFINITION(defaultDB(), NULL, $word);
        $d->set_lang("en");
        $d->set_value($definition);
        $d = $word->add_definition($d);
    }
    if ($word !== NULL and $t !== NULL) {
        run_template($word, "", $t, $arg, [], [], FALSE);
    }
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:15,代码来源:load_eo.php

示例3: get_template

function get_template($conj)
{
    return safe_get(0, defaultDB()->searcher()->spart("verb")->name($conj)->only_with_attr(ATTR("template", "true"))->all());
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:4,代码来源:entries2.php

示例4: sro

<?php

require_once '/var/www/config.php';
sro('/Includes/mysql.php');
sro('/Includes/session.php');
sro('/Includes/functions.php');
sro('/PHP5/lib/PHPLang/db.php');
if (!requireRank(3, FALSE)) {
    echo "Insufficient permissions";
} else {
    if (array_key_exists("from", $_GET) and array_key_exists("to", $_GET) and array_key_exists("type", $_GET) and is_numeric($_GET["from"]) and is_numeric($_GET["to"])) {
        $cons = [[$_GET["from"], $_GET["to"]]];
        if (array_key_exists("mutual", $_GET) and $_GET["mutual"] === "true") {
            $cons = [$cons[0], [$_GET["to"], $_GET["from"]]];
        }
        foreach ($cons as list($ab, $ad)) {
            $w = WORD(defaultDB(), intval($ab));
            $t = WORD(defaultDB(), intval($ad));
            $c = CONNECTION($w, $t, $_GET["type"]);
            $w->add_connection($c);
        }
        exit("success");
    } else {
        exit("\$_GET was invalid");
    }
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:26,代码来源:add-connection.php

示例5: foreach

<span data-i18n="word_formatting">Word formatting</span>:
<select id="la_ipa" style="width: 200px">
</select>
<br>

<label><span data-i18n="archaic_translations">Archai&#x308;c translations</span>:
<input id="archtrans" type="checkbox"></label>

<br><br>

<span data-i18n="order_cases">Order of cases</span>:
<div>
<ul id="cases">
<?php 
foreach (defaultDB()->get_mgr("la", "noun")->key2values["case"] as $case) {
    ?>
<li><span class="value"><?php 
    echo ucfirst($case);
    ?>
</span>
<?php 
}
?>
</ul>
</div>

<span id="word-format-ex" class="format-word-la">
Exemplum verbōrum: Salvē! Quid agis? Hoc verbum habet multās fōrmās: oppugnātus‣, et hoc īnflexum: aestⱶmāvissem. Jussa! Euge!
</span>
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:29,代码来源:preferences.php

示例6: substr

        if ($reverse = substr($attr, 0, 1) === "!") {
            $attr = substr($attr, 1);
        }
        if (strpos($attr, "=") === FALSE) {
            $a = ATTR($attr);
        } else {
            list($name, $value) = explode("=", $attr, 2);
            $a = ATTR($name, $value);
        }
        if ($a !== NULL) {
            if (!$reverse) {
                $searcher = $searcher->only_with_attr($a);
            } else {
                $searcher = $searcher->only_without_attr($a);
            }
        }
    }
    $list = $searcher->all();
} else {
    $list = [];
    foreach ($ids as $id) {
        $list[] = WORD(defaultDB(), intval($id));
    }
}
$res = vec_norm(array_map(function ($e) {
    if (no_format($e)) {
        return ["data" => $e->name(), "value" => $e->id() . "", "display" => $e->info()];
    }
    return ["data" => $e->name(), "value" => $e->id() . "", "display" => format_word($e->info())];
}, $list));
echo json_encode($res);
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:31,代码来源:get-info-json.php

示例7: exit

                     $w->add_path($p);
                 }
                 exit("success");
             } else {
                 $p = PATH($w);
                 $p->set($names[0]);
                 exit("success");
             }
         }
     }
 }
 $ignore = array_map(function ($a) {
     return explode("/", $a);
 }, $ignore);
 // Template: passed by name, spart from word, attr template=true
 $t = defaultDB()->searcher();
 $t = $t->spart($w->speechpart());
 $t = $t->name($template);
 $t = $t->only_with_attr(ATTR("template", "true"));
 $t = $t->all();
 //error_log(var_export(array_map(function($a){return$a->id();},$t),1));
 if (count($t) === 0) {
     exit("Could not find template with name: " . $template);
 } elseif (count($t) !== 1) {
     exit("Ambiguous template name (please remove duplicate template(s))");
 }
 if ($path === "common") {
     if (($s = run_template($w, PATH($w, "feminine"), $t[0], $forms, $ignore, $changes, FALSE)) === NULL) {
         if (($s = run_template($w, PATH($w, "masculine"), $t[0], $forms, $ignore, $changes, FALSE)) === NULL) {
             exit("success");
         } else {
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:31,代码来源:add-word-complete.php

示例8: _process_value

 private function _process_value($v)
 {
     return _process_value($v, $this->selections, defaultDB());
 }
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:4,代码来源:QuizType.php

示例9: foreach

    }
    foreach ($res as &$r) {
        $r = ["correct" => $r->word()->id() === $pick_db["word"]->id(), "value" => ((string) $r->path() ? "(" . $r->path() . ") " : "") . str_replace("\n", ", ", $r->value())];
    }
    return $res;
}, "choices0-tooltip" => "Pick correct definition"]]], "random-definitions-stage28-29-fr" => ["name" => "Stage 28–29 Vocabulary (FR)", "category" => "Vocabulary", "lang" => "la", "options" => [["help" => "Choose a correct definition for the given word", "selections" => ["word" => function ($_, $db, $path) {
    $s = $db->searcher();
    $s->stmt .= "\n\t\t\t\t\t\tWHERE word_id IN (\n\t\t\t\t\t\t\tSELECT word_id FROM definitions\n\t\t\t\t\t\t\tWHERE def_lang = 'en'\n\t\t\t\t\t\t\tAND def_type IS NULL\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND word_lang = 'la'\n\t\t\t\t\t\tAND word_id NOT IN (\n\t\t\t\t\t\t\tSELECT word_id FROM attributes\n\t\t\t\t\t\t\tWHERE attr_tag = 'template' OR attr_tag = 'hidden'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\tSELECT attr_value FROM attributes\n\t\t\t\t\t\t\tWHERE word_id = words.word_id\n\t\t\t\t\t\t\tAND attr_tag = 'clc-stage' \n\t\t\t\t\t\t) IN (28,29)";
    $s->args = [];
    return $s->rand();
}], "sentence" => [$OP_LQUOTE, function ($pick_db) {
    return format_word($pick_db["word"]->name());
}, $OP_RQUOTE, $OP_COLON, $OP_USER_INPUT], "answer0-language" => "en", "answer0" => function ($pick_db, $db) {
    global $mysqli;
    $query = $mysqli->prepare("\n\t\t\t\t\tSELECT DISTINCT def_id FROM definitions\n\t\t\t\t\tWHERE def_lang = 'en'\n\t\t\t\t\tAND def_type IS NULL\n\t\t\t\t\tAND word_id = (?)\n\t\t\t\t");
    $res = NULL;
    sql_getmany($query, $res, ["i", $pick_db["word"]->id()]);
    $query->close();
    if (!$res) {
        return NULL;
    }
    $ret = [];
    $ret2 = [];
    foreach ($res as $r) {
        $ret = array_merge($ret, explode("\n", definition(defaultDB(), $r)->value()));
    }
    foreach ($ret as $r) {
        $ret2 = array_merge($ret2, array_map("trim", explode(",", $r)));
    }
    return ["correct" => explode(",", $ret[0]), "acceptable" => $ret2];
}, "answer0-tooltip" => "Type correct definition"]]], "009" => ["name" => "Synonyms", "lang" => "la", "category" => "Vocabulary", "n_questions" => "auto", "options" => [make_matching(["cædō" => "interficiō", "exeō" => "discēdō", "pulsō" => "verberō", "volō" => "cupiō"]), make_matching(["turba" => "multitūdō", "mīles" => "arma", "imperātor" => "rēx"])]]]);
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:31,代码来源:vocab.php

示例10: sro

<?php

require_once '/var/www/config.php';
sro('/Includes/mysql.php');
sro('/Includes/session.php');
sro('/Includes/functions.php');
sro('/PHP5/lib/PHPLang/db.php');
if (!requireRank(3, FALSE)) {
    echo "Insufficient permissions";
} else {
    if (array_key_exists("id", $_GET) and array_key_exists("path", $_GET) and is_numeric($_GET["id"])) {
        $w = WORD(defaultDB(), intval($_GET["id"]));
        $w->read_paths();
        $p = PATH($w, $_GET["path"]);
        foreach ($w->paths() as $_) {
            if ((string) $_ === (string) $p) {
                $p = $_;
            }
        }
        if ($p->id() === NULL) {
            exit("Path {$p} did not exist");
        }
        if (!$p->valid()) {
            exit("Path {$p} was invalid");
        }
        $p->remove();
        exit("success");
    } else {
        exit("\$_GET was invalid");
    }
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:31,代码来源:delete-path.php

示例11: sro

<?php

require_once '/var/www/config.php';
sro('/Includes/mysql.php');
sro('/Includes/session.php');
sro('/Includes/functions.php');
sro('/PHP5/lib/PHPLang/db.php');
if (!requireRank(3, FALSE)) {
    echo "Insufficient permissions";
} else {
    if (array_key_exists("from", $_GET) and array_key_exists("to", $_GET) and array_key_exists("type", $_GET) and is_numeric($_GET["from"]) and is_numeric($_GET["to"])) {
        $w = WORD(defaultDB(), intval($_GET["from"]));
        $t = WORD(defaultDB(), intval($_GET["to"]));
        $c = CONNECTION($w, $t, $_GET["type"]);
        $w->remove_connection($c);
        exit("success");
    } else {
        exit("\$_GET was invalid");
    }
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:20,代码来源:delete-connection.php

示例12: sro

<?php

require_once '/var/www/config.php';
sro('/Includes/mysql.php');
sro('/Includes/session.php');
sro('/Includes/functions.php');
sro('/PHP5/lib/PHPLang/sql_stmts.php');
sro('/PHP5/lib/PHPLang/db.php');
sro('/PHP5/lib/PHPLang/display.php');
sro('/PHP5/lib/PHPLang/misc.php');
global $mysqli;
$w = defaultDB()->searcher()->lang('la')->only_without_attr(ATTR('template'));
$ws = $w->all();
?>
<table class="inflection"><?php 
foreach ($ws as $i => $word) {
    ?>
<tr><td><ol start="<?php 
    echo $i + 1;
    ?>
"><li><a class="word-ref format-word-<?php 
    echo $word->lang();
    ?>
" href="dictionary.php?id=<?php 
    echo $word->id();
    ?>
"><?php 
    echo $word->name();
    ?>
</ol></td><td style="border-spacing: 0px; padding: 0px;"><?php 
    display_definitions($word);
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:31,代码来源:word_list.php

示例13: do_template

function do_template($temp, $db = NULL, &$pick_db = NULL, &$reason = NULL)
{
    if ($db === NULL) {
        $db = defaultDB();
    }
    if (is_string($temp)) {
        return $temp;
    }
    $repeats = 0;
    $sentence = NULL;
    $reason = NULL;
    $ignore = NULL;
    $reset = [];
    if (is_array($pick_db)) {
        $reset = [];
        foreach ($pick_db as $k => $_) {
            $reset[$k] = _process_value($_, $reset, $db);
        }
    }
    while ($repeats < 1 and $sentence === NULL) {
        $repeats += 1;
        $sentence = [];
        $pick_db = $reset;
        foreach ($temp as $k => $t) {
            $res = do_pick($t, $db, $pick_db, $reason);
            if ($res === NULL) {
                $reason .= " on key {$k}";
                $reason .= " (picks were " . dump_pick_db($pick_db) . ")";
                $sentence = NULL;
                break;
            } elseif ($res !== FALSE) {
                $sentence[$k] = $res;
            }
        }
    }
    if ($sentence !== NULL) {
        return array_values($sentence);
    }
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:39,代码来源:make_example.php

示例14: select2_getlangs

function select2_getlangs()
{
    $langs = [];
    $db = defaultDB();
    foreach ($db->langs() as $l) {
        $langs[] = ["id" => $l, "text" => format_lang($l)];
    }
    return $langs;
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:9,代码来源:display.php

示例15: sro

<?php

require_once '/var/www/config.php';
sro('/Includes/mysql.php');
sro('/Includes/session.php');
sro('/Includes/functions.php');
sro('/PHP5/lib/PHPLang/db.php');
if (!requireRank(3, FALSE)) {
    echo "Insufficient permissions";
} else {
    if (array_key_exists("id", $_GET) and array_key_exists("val", $_GET) and array_key_exists("path", $_GET) and is_numeric($_GET["id"])) {
        $w = WORD(defaultDB(), intval($_GET["id"]));
        $d = PRONUNCIATION(defaultDB(), NULL, $w);
        $d->set_type("IPA");
        $d->set_value($_GET["val"]);
        //error_log(var_export($d->value(),1)." should be ".var_export($_GET["val"],1));
        if ($_GET["path"]) {
            $p = PATH($w, $_GET["path"]);
            $d->set_path($p);
        }
        $d = $w->add_pronuncation($d);
        exit("success");
    } else {
        exit("\$_GET was invalid (" . var_export($_GET, 1) . ")");
    }
}
开发者ID:NasalMusician,项目名称:Pantheum,代码行数:26,代码来源:add-pronunciation.php


注:本文中的defaultDB函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。