本文整理汇总了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) {
示例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;
}
}
示例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();
}