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


PHP Definition::load方法代码示例

本文整理汇总了PHP中Definition::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::load方法的具体用法?PHP Definition::load怎么用?PHP Definition::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Definition的用法示例。


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

示例1: file

require_once "../../phplib/util.php";
$lines = file('/tmp/rez_bio.txt');
foreach ($lines as $line) {
    $components = split('---', $line);
    if (count($components) != 3) {
        echo "Bad line: {$line}";
        continue;
    }
    $id = trim($components[0]);
    $name = trim(strtolower($components[1]));
    $latinList = trim(strtolower($components[2]));
    if (!is_numeric($id)) {
        echo "Bad id: {$id}\n";
        continue;
    }
    $definition = Definition::load($id);
    $words = Word::loadByDefinitionId($id);
    $nameExists = false;
    foreach ($words as $word) {
        if (strtolower($word->name) == $name) {
            $nameExists = true;
        }
    }
    if (!$nameExists) {
        echo "Name does not match id: {$name}, {$id}";
        continue;
    }
    $dnames = Word::joinCommaSeparatedDnames($words);
    echo "Adding words for {$id} ({$dnames})\n";
    $latinNames = split('\\|', $latinList);
    foreach ($latinNames as $latinName) {
开发者ID:florinp,项目名称:dexonline,代码行数:31,代码来源:addBioLatinNames.php

示例2: file

<?php

require_once '../../phplib/util.php';
$defIds = file('defIds.txt');
foreach ($defIds as $i => $defId) {
    $defId = trim($defId);
    if (!$defId) {
        continue;
    }
    $def = Definition::load($defId);
    print $i + 1 . "/" . count($defIds) . " {$defId}\n";
    print "{$def->internalRep}\n";
    $newRep = '';
    $len = mb_strlen($def->internalRep);
    for ($i = 0; $i < $len; $i++) {
        $c = text_getCharAt($def->internalRep, $i);
        if ($c == '|') {
            $mid = mb_strpos($def->internalRep, '|', $i + 1);
            $close = mb_strpos($def->internalRep, '|', $mid + 1);
            $text = mb_substr($def->internalRep, $i + 1, $mid - $i - 1);
            $ref = mb_substr($def->internalRep, $mid + 1, $close - $mid - 1);
            print "|{$text}|{$ref}|\n";
            $i = $close;
            $c = readChar();
            if ($c == 'k') {
                $newRep .= "|{$text}|{$ref}|";
            } else {
                if ($c == 'd') {
                    $newRep .= $text;
                }
            }
开发者ID:florinp,项目名称:dexonline,代码行数:31,代码来源:deleteReferences.php

示例3: mysql_query

<?php

require_once "../../phplib/util.php";
$query = "select Id from Definition where Lexicon = '' and Status = 0";
$dbResult = mysql_query($query);
while ($row = mysql_fetch_assoc($dbResult)) {
    $def = Definition::load($row['Id']);
    $words = Word::loadByDefinitionId($def->id);
    $dnames = Word::joinCommaSeparatedDnames($words);
    $def->lexicon = text_dnameToLexicon($words[0]->dname);
    print "Fixing definition " . $def->id . " / {$dnames}; new Lexicon is " . $def->lexicon . "\n";
    $def->save();
}
开发者ID:florinp,项目名称:dexonline,代码行数:13,代码来源:fixEmptyLexiconFields.php


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