public static function FindStatisticFromFile($bookdir, $keyword) { if (!isset($keyword)) { return ""; } $pathfilename = ChineseCharacterStatistic::BookDir2outfile($bookdir, true); syslog(0, $bookdir . $keyword); if (!file_exists($pathfilename)) { return $keyword; } //return $pathfilename . $keyword; $data = file_get_contents($pathfilename); if (false == $data) { syslog(0, "failed to read file:" . $pathfilename); } $bChinese = ChineseCharacterStatistic::IsChaninese($bookdir); $map = new MapChineseGbEnglishWord(); $keyword = $map->getChineseGB($keyword, $bChinese); //ChineseCharacterStatistic::LanguageTranslate($bookdir, $keyword); $out = ChineseCharacterStatistic::FindStatisticFromData($data, $keyword); return $out; }
$db = $this->connect(); $sql = "SELECT * from MapChineseGbEnglishWord"; //syslog(LOG_DEBUG, $sql ); $result = $db->query($sql); if (!$result) { $err = $db->errorInfo(); //errLastSet($err[2]); //errLog(0, "Err database ".$sql, $err[2]); echo $err[2] . "<br>"; } else { while ($row = $result->fetch()) { print_r($row); print "&#" . $row[1] . ";<br>"; } } return $this; } } //class MysqlBase if (0 && isset($_REQUEST["key"])) { //================= //usage sample //================= print "<br>======<br>"; /////////////////// $db = new MapChineseGbEnglishWord(); echo $db->getChineseGB($_REQUEST["key"], true) . " - chinese<BR>"; echo $db->getChineseGB($_REQUEST["key"], false) . " - english<BR>"; print "<br>======<br>"; $ret = $db->showDB(); }