瀏覽代碼

修改 wbw_block表名为define 字符串

visuddhinanda 4 年之前
父節點
當前提交
01bbe22721

+ 1 - 1
app/channal/my_channal_post.php

@@ -57,7 +57,7 @@ else{
 
 	// 设置 逐词译库可见性
 	PDO_Connect(_FILE_DB_USER_WBW_);
-	$query="UPDATE wbw_block SET lang = ?  , status = ? where  channal = ?  ";
+	$query="UPDATE "._TABLE_USER_WBW_BLOCK_." SET lang = ?  , status = ? where  channal = ?  ";
 	$sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
 	if (!$sth || ($sth && $sth->errorCode() != 0)) {
 		$error = PDO_ErrorInfo();

+ 2 - 2
app/db/wbw_block.php

@@ -6,13 +6,13 @@ require_once "../channal/function.php";
 class WbwBlock extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_USER_WBW_, "wbw_block", "", "",$redis);
+		parent::__construct(_FILE_DB_USER_WBW_, _TABLE_USER_WBW_BLOCK_, "", "",$redis);
     }
 
 	public function getPower($blockId){
 		$channelInfo = new Channal($this->redis);
 		$power = 0;
-		$query = "SELECT channal,owner from wbw_block   where id= ?  ";
+		$query = "SELECT channal,owner from "._TABLE_USER_WBW_BLOCK_."   where id= ?  ";
 		$row = $this->fetch($query,array($blockId));
 		if($row ){
 			if(empty($row["channal"])){

+ 2 - 2
app/doc/edit_wbw.php

@@ -58,8 +58,8 @@ foreach($Fetch as $row){
     echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["lang"].'</div>';
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
     // 查询逐词解析库
-    PDO_Connect(""._FILE_DB_USER_WBW_);
-    $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
+    PDO_Connect(_FILE_DB_USER_WBW_);
+    $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
     $FetchWBW = PDO_FetchOne($query);
     echo '</div>';
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';

+ 8 - 8
app/doc/fork.php

@@ -59,8 +59,8 @@ if (isset($_GET["channel"]) == false) {
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["name"] . '</div>';
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-        PDO_Connect("" . _FILE_DB_USER_WBW_);
-        $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        PDO_Connect(_FILE_DB_USER_WBW_);
+        $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -73,8 +73,8 @@ if (isset($_GET["channel"]) == false) {
         echo '</div>';
 
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-        PDO_Connect("" . _FILE_DB_SENTENCE_);
-        $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        PDO_Connect(_FILE_DB_SENTENCE_);
+        $query = "SELECT count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -101,7 +101,7 @@ if (isset($_GET["channel"]) == false) {
 {
     PDO_Connect("" . _FILE_DB_FILEINDEX_);
     $doc_id = $_GET["doc_id"];
-    $query = "select * from fileindex where id= ? ";
+    $query = "SELECT * from fileindex where id= ? ";
     $Fetch = PDO_FetchAll($query, array($doc_id));
     $iFetch = count($Fetch);
     if ($iFetch > 0) {
@@ -120,7 +120,7 @@ if (isset($_GET["channel"]) == false) {
         } else {
             //别人的文档
             //查询自己是否以前打开过
-            $query = "select * from fileindex where parent_id='{$doc_id}' and user_id='{$uid}' ";
+            $query = "SELECT * from fileindex where parent_id='{$doc_id}' and user_id='{$uid}' ";
             $FetchSelf = PDO_FetchAll($query);
             $iFetchSelf = count($FetchSelf);
             if ($iFetchSelf > 0) {
@@ -234,7 +234,7 @@ if (isset($_GET["channel"]) == false) {
                             case 6:
                                 #逐词解析
                                 $blockid = $blocks[$i]->block_id;
-                                $query = "select * from wbw_block where id= ? ";
+                                $query = "select * from "._TABLE_USER_WBW_BLOCK_." where id= ? ";
                                 $stmt = $dbhWBW->prepare($query);
                                 $stmt->execute(array($blockid));
                                 $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -288,7 +288,7 @@ if (isset($_GET["channel"]) == false) {
 
                     if (count($arrNewBlock) > 0) {
                         $dbhWBW->beginTransaction();
-                        $query = "INSERT INTO wbw_block ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                        $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
                         $stmtNewBlock = $dbhWBW->prepare($query);
                         foreach ($arrNewBlock as $oneParam) {
                             $stmtNewBlock->execute($oneParam);

+ 9 - 9
app/doc/fork_channel.php

@@ -70,7 +70,7 @@ if (isset($_GET["dest_channel"]) == false) {
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["name"] . '</div>';
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-        $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $query = "select count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -110,7 +110,7 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
         } else {
             //别人的文档
             //查询以前自己是否曾经复刻
-            $query = "select * from wbw_block where parent_channel=? and owner=? ";
+            $query = "SELECT * from "._TABLE_USER_WBW_BLOCK_." where parent_channel=? and owner=? ";
             $FetchSelf = PDO_FetchAll($query,array($_GET["src_channel"],$_COOKIE["userid"]));
             $iFetchSelf = count($FetchSelf);
             if ($iFetchSelf > 0) {
@@ -139,7 +139,7 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
 
                     $blocks = $_para;
                     for ($i = 0; $i < count($blocks); $i++) {
-						$query = "select id from wbw_block where book= ? and paragraph = ? and channal = ? ";
+						$query = "SELECT id from "._TABLE_USER_WBW_BLOCK_." where book= ? and paragraph = ? and channal = ? ";
 						$stmt = $dbhWBW->prepare($query);
 						$stmt->execute(array($_GET["book"],$iPara,$_GET["dest_channel"]));
 						$fDest = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -149,7 +149,7 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
 						}
 						#逐词解析
 						$iPara = $blocks[$i];
-						$query = "select * from wbw_block where book= ? and paragraph = ? and channal = ? ";
+						$query = "SELECT * from "._TABLE_USER_WBW_BLOCK_." where book= ? and paragraph = ? and channal = ? ";
 						$stmt = $dbhWBW->prepare($query);
 						$stmt->execute(array($_GET["book"],$iPara,$_GET["src_channel"]));
 						$fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -178,7 +178,7 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
 								));
 						}
 
-						$query = "select * from wbw where block_id= ? ";
+						$query = "SELECT * from "._TABLE_USER_WBW_." where block_id= ? ";
 						$stmtWBW = $dbhWBW->prepare($query);
 						$stmtWBW->execute(array($fBlock[0]["id"]));
 						$fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
@@ -204,14 +204,14 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
 					# 查找目标block是否存在
 
 					//删除旧的逐词解析block数据块
-					$query = "DELETE from wbw_block where  paragraph = ? AND book = ? AND channal = ? ";
+					$query = "DELETE from "._TABLE_USER_WBW_BLOCK_." where  paragraph = ? AND book = ? AND channal = ? ";
 					$stmt = $dbhWBW->prepare($query);
 					$stmt->execute(array($iPara,$_GET["book"],$_GET["dest_channel"]));
 					
                     //新增逐词解析block数据块
                     if (count($arrNewBlock) > 0) {
                         $dbhWBW->beginTransaction();
-                        $query = "INSERT INTO wbw_block ('id','parent_id','channal','parent_channel','owner','book','paragraph','style','lang','status','modify_time','receive_time','create_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
+                        $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id','parent_id','channal','parent_channel','owner','book','paragraph','style','lang','status','modify_time','receive_time','create_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
                         $stmtNewBlock = $dbhWBW->prepare($query);
                         foreach ($arrNewBlock as $oneParam) {
                             $stmtNewBlock->execute($oneParam);
@@ -231,7 +231,7 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
 
 					//删除逐词解析数据块
 					if(isset($destId)){
-						$query = "DELETE from wbw where  block_id = ? ";
+						$query = "DELETE from "._TABLE_USER_WBW_." where  block_id = ? ";
 						$stmt = $dbhWBW->prepare($query);
 						$stmt->execute($destId);
 					}
@@ -239,7 +239,7 @@ $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
                     if (count($arrNewBlockData) > 0) {
                         // 开始一个事务,逐词解析数据 关闭自动提交
                         $dbhWBW->beginTransaction();
-                        $query = "INSERT INTO wbw ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                        $query = "INSERT INTO "._TABLE_USER_WBW_." ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
                         $stmtWbwData = $dbhWBW->prepare($query);
                         foreach ($arrNewBlockData as $oneParam) {
                             $stmtWbwData->execute($oneParam);

+ 1 - 1
app/doc/load_channal_para.php

@@ -45,7 +45,7 @@ $dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 foreach ($paralist as $para) {
 
     $albumId = UUID::v4();
-    $query = "SELECT * FROM wbw_block WHERE channal=? AND book = ? AND paragraph = ?  ";
+    $query = "SELECT * FROM "._TABLE_USER_WBW_BLOCK_." WHERE channal=? AND book = ? AND paragraph = ?  ";
     $stmt = $dh_wbw->prepare($query);
     $stmt->execute(array($channal, $book, $para));
     $FetchBlock = $stmt->fetch(PDO::FETCH_ASSOC);

+ 2 - 2
app/doc/pcs2db.php

@@ -58,7 +58,7 @@ if (isset($_GET["channel"]) == false) {
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
         PDO_Connect("" . _FILE_DB_USER_WBW_);
-        $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $query = "select count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -343,7 +343,7 @@ $dataBlock = $xml->xpath('//block');
     #插入逐词解析块数据
     if (count($arrNewBlock) > 0) {
         $dbhWBW->beginTransaction();
-        $query = "INSERT INTO wbw_block (
+        $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." (
 										'id',
 										'parent_id',
 										'channal',

+ 10 - 6
app/path.php

@@ -50,14 +50,17 @@ define("_DIR_USER_IMG_", __DIR__ . "/../tmp/user/media/3");
 define("_DIR_USER_IMG_LINK_", "../../tmp/user/media/3");
 define("_DIR_MYDOCUMENT_", "/my_document");
 
+# 逐词解析字典文件
+define("_FILE_DB_WBW1_",  __DIR__ . "/../tmp/user/wbw.db3");
+
 #数据库
 # 数据库基本参数
 define("_DB_ENGIN_", "sqlite");
 
 define("_DB_HOST_", "localhost");
 define("_DB_PORT_", "5432");
-define("_DB_USERNAME_", "");
-define("_DB_PASSWORD_", "");
+define("_DB_USERNAME_", "postgres");
+define("_DB_PASSWORD_", "123456");
 define("_DB_NAME_", "mint");
 
 //语料库数据表 pali canon db file 
@@ -84,7 +87,8 @@ define("_FILE_DB_PALI_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/
 //页码对应
 define("_FILE_DB_PAGE_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pagemap.db3");
 //以书为单位的单词汇总表
-define("_FILE_DB_BOOK_WORD_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/bookword.db3");
+define("_FILE_DB_BOOK_WORD_", "pgsql:host="._DB_HOST_.";port="._DB_PORT_.";dbname="._DB_NAME_.";user="._DB_USERNAME_.";password="._DB_PASSWORD_.";");
+//define("_FILE_DB_BOOK_WORD_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/bookword.db3");
 define("_TABLE_BOOK_WORD_", "bookword");
 //黑体字数据表
 define("_FILE_DB_BOLD_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/bold.db3");
@@ -123,14 +127,15 @@ define("_TABLE_PART_", "part");
 //读写频繁
 # 逐词解析表
 define("_FILE_DB_USER_WBW_", "sqlite:" . __DIR__ . "/../tmp/user/user_wbw.db3");
+define("_TABLE_USER_WBW_", "wbw");
+define("_TABLE_USER_WBW_BLOCK_", "wbw_block");
 # 译文
 define("_FILE_DB_SENTENCE_", "sqlite:" . __DIR__ . "/../tmp/user/sentence.db3");
 # 译文编辑历史
 define("_FILE_DB_USER_SENTENCE_HISTORAY_", "sqlite:" . __DIR__ . "/../tmp/user/usent_historay.db3");
 # 逐词解析字典
 define("_FILE_DB_WBW_", "sqlite:" . __DIR__ . "/../tmp/user/wbw.db3");
-# 逐词解析字典文件
-define("_FILE_DB_WBW1_",  __DIR__ . "/../tmp/user/wbw.db3");
+
 
 //写入频繁 读取不频繁
 # 用户行为记录
@@ -175,7 +180,6 @@ define("_FILE_DB_MEDIA_", "sqlite:" . __DIR__ . "/../tmp/user/media.db3");
 define("_FILE_DB_USER_DICT_", "sqlite:" . __DIR__ . "/../tmp/user/udict.db3");
 
 
-
 # 评论 尚未启用
 define("_FILE_DB_COMMENTS_", "sqlite:" . __DIR__ . "/../tmp/user/comments.db3");
 

+ 1 - 0
app/search/paliword_search.php

@@ -162,6 +162,7 @@ switch ($op) {
             $time_start = microtime_float();
 
             PDO_Connect(_FILE_DB_PALI_INDEX_);
+			//TODO 在没有查到书的时候$strFirstBookList为 (  需要修改
             $query = "SELECT book,paragraph, wordindex FROM word WHERE \"wordindex\" in $strQueryWordId and book in $strFirstBookList group by book,paragraph LIMIT 0,20";
             $Fetch = PDO_FetchAll($query);
             //echo "<div>$query</div>";

+ 2 - 2
app/studio/project.php

@@ -203,7 +203,7 @@ switch ($op) {
 
                             PDO_Connect(_FILE_DB_USER_WBW_);
                             $PDO->beginTransaction();
-                            $query = "INSERT INTO wbw_block ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                            $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
                             $stmt = $PDO->prepare($query);
                             foreach ($block_data as $oneParam) {
                                 $stmt->execute($oneParam);
@@ -356,7 +356,7 @@ switch ($op) {
                     echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
                     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
                     PDO_Connect( _FILE_DB_USER_WBW_);
-                    $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
+                    $query = "select count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
                     $FetchWBW = PDO_FetchOne($query);
                     echo '</div>';
                     echo '<div class="title" style="flex:2;padding-bottom:5px;">';

+ 1 - 1
app/studio/project_load_article.php

@@ -32,7 +32,7 @@ if (count($Fetch) > 0) {
             case "6":
                 {
                     $albumId = UUID::v4();
-                    $query = "select * from wbw_block where id='" . $block->block_id . "'";
+                    $query = "select * from "._TABLE_USER_WBW_BLOCK_." where id='" . $block->block_id . "'";
                     $stmt = $dh_wbw->query($query);
                     $FetchBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
                     echo "\n<block>";

+ 1 - 1
app/studio/project_load_db.php

@@ -31,7 +31,7 @@ if (count($Fetch) > 0) {
             case "6":
                 {
                     $albumId = UUID::v4();
-                    $query = "select * from wbw_block where id='" . $block->block_id . "'";
+                    $query = "select * from "._TABLE_USER_WBW_BLOCK_." where id='" . $block->block_id . "'";
                     $stmt = $dh_wbw->query($query);
                     $FetchBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
                     echo "\n<block>";

+ 1 - 1
app/sync/table_wbw_block.php

@@ -6,7 +6,7 @@ require_once "../sync/function.php";
 
 $input = (object) [
     "database" =>  _FILE_DB_USER_WBW_,
-    "table" =>  "wbw_block",
+    "table" =>  _TABLE_USER_WBW_BLOCK_,
     "uuid" =>  "id",
     "sync_id" =>  ["id"],
     "modify_time" =>  "modify_time",

+ 2 - 2
app/uwbw/create_wbw.php

@@ -78,7 +78,7 @@ $dbh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 foreach ($_para as $key => $para) {
     # code...
-    $query = "SELECT count(*) FROM wbw_block WHERE channal = ? AND book= ? and paragraph = ? ";
+    $query = "SELECT count(*) FROM "._TABLE_USER_WBW_BLOCK_." WHERE channal = ? AND book= ? and paragraph = ? ";
     $FetchWBW = PDO_FetchOne($query,array($_channel,$_book,$para));
     if($FetchWBW==0){
         #建立
@@ -107,7 +107,7 @@ foreach ($_para as $key => $para) {
                                         "readonly"=>false
                                     );
         $dbh_wbw->beginTransaction();
-        $query="INSERT INTO wbw_block ('id',
+        $query="INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id',
                                                                  'parent_id',
                                                                  'channal',
                                                                  'owner',

+ 2 - 2
app/uwbw/wbw_channel_list.php

@@ -56,7 +56,7 @@ foreach ($coop_channal as $key => $value) {
 
 # 查询全网公开 的
 PDO_Connect( _FILE_DB_USER_WBW_);
-$query = "SELECT  channal FROM wbw_block WHERE  paragraph IN ($place_holders)  AND book = ? AND channal IS NOT NULL AND status = 30 group by channal ";
+$query = "SELECT  channal FROM "._TABLE_USER_WBW_BLOCK_." WHERE  paragraph IN ($place_holders)  AND book = ? AND channal IS NOT NULL AND status = 30 group by channal ";
 $publicChannel = PDO_FetchAll($query, $params);
 foreach ($publicChannel as $key => $channel) {
 	# code...
@@ -73,7 +73,7 @@ $outputData = array();
 foreach ($channelList as $key => $row) {
     $queryParam = $params;
     $queryParam[] = $key;
-    $query = "SELECT count(*) FROM wbw_block WHERE  paragraph IN ($place_holders)  AND book = ? AND channal = ? ";
+    $query = "SELECT count(*) FROM "._TABLE_USER_WBW_BLOCK_." WHERE  paragraph IN ($place_holders)  AND book = ? AND channal = ? ";
     $wbwCount = PDO_FetchOne($query, $queryParam);
     $channelList[$key]["wbw_para"] = $wbwCount;
     $channelList[$key]["count"] = count($_para);