// stop rebuild if ($stop_rebuild !== null) { echo "中止索引重建 ...\n"; $index->stopRebuild(); } // begin rebuild if ($rebuild !== null) { echo "开始重建索引 ...\n"; $index->beginRebuild(); } // import data from source $fid = $xs->getFieldId(); if (!empty($source)) { echo "初始化数据源 ... {$source} \n"; $total = $total_ok = $total_failed = 0; $src = XSDataSource::instance($source, strpos($source, ':') ? $sql : $file); $dcs = $src->getCharset(); if ($dcs === false) { $dcs = $charset === null ? 'UTF-8' : $charset; } echo "开始批量导入数据 (" . (empty($file) ? "请直接输入数据" : $file) . ") ...\n"; XSUtil::flush(); $index->setTimeout(0); $index->openBuffer(); while ($data = $src->getData()) { $doc = new XSDocument($dcs); if ($source == 'csv') { $data = csvTransform($data); if (is_null($data)) { continue; }
/** * 返回数据库输出字符集 * @return mixed 如果数据库不支持 UTF-8 转换则返回 false */ public function getCharset() { if ($this->db->setUtf8()) { return 'UTF-8'; } return parent::getCharset(); }