Ver Fonte

pali_text 数据库支持pg

visuddhinanda há 4 anos atrás
pai
commit
8937fe54dc

+ 2 - 2
app/admin/db_update_cs6_para.php

@@ -4,7 +4,7 @@ require_once "../public/_pdo.php";
 require_once "../path.php";
 
 PDO_Connect(_FILE_DB_PALITEXT_);
-$query = "SELECT * from books where 1";
+$query = "SELECT * from "._TABLE_PALI_BOOK_NAME_." where 1";
 $books = PDO_FetchAll($query);
 
 PDO_Connect(_FILE_DB_PAGE_INDEX_);
@@ -13,7 +13,7 @@ $irow = 0;
 if (($fp = fopen("./cs6_para.csv", "r")) !== false) {
     // 开始一个事务,关闭自动提交
     $PDO->beginTransaction();
-    $query = "INSERT INTO cs6_para ('book','para','bookid','cspara','book_name') VALUES (  ? , ? , ? , ? , ? )";
+    $query = "INSERT INTO cs6_para (book,para,bookid,cspara,book_name) VALUES (  ? , ? , ? , ? , ? )";
     $stmt = $PDO->prepare($query);
 
     // 提交更改

+ 1 - 1
app/db/pali_text.php

@@ -5,7 +5,7 @@ require_once "../db/table.php";
 class PaliText extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_PALITEXT_, "pali_text", "", "",$redis);
+		parent::__construct(_FILE_DB_PALITEXT_, _TABLE_PALI_TEXT_, "", "",$redis);
     }
 
 	public function index(){

+ 2 - 2
app/db/table.php

@@ -19,14 +19,14 @@ class Table
 	public $medoo;
 	protected $redisProfix;
     function __construct($db,$table,$user="",$password="",$redis=false) {
-        $this->dbh = new PDO($db, $user, $password,array(PDO::ATTR_PERSISTENT=>true));
+        $this->dbh = new PDO($db, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 		$database = new Medoo([
 			// Initialized and connected PDO object.
 			'pdo' => $this->dbh,
 		 
 			// [optional] Medoo will have different handle method according to different database type.
-			'type' => 'sqlite'
+			'type' => _DB_ENGIN_
 		]);
 		
 		$this->medoo = $database;

+ 1 - 1
app/doc/edit_wbw.php

@@ -9,7 +9,7 @@ require_once "../public/load_lang.php";
 $_book = $_POST["book"];
 $_para = json_decode($_POST["para"]);
 //判断单词数量 太大的不能加载
-PDO_Connect(""._FILE_DB_PALITEXT_);
+PDO_Connect(_FILE_DB_PALITEXT_);
 $params = array(1, 21, 63, 171);
 /*  创建一个填充了和params相同数量占位符的字符串 */
 $place_holders = implode(',', array_fill(0, count($_para), '?'));

+ 7 - 5
app/install/db_insert_palitext.php

@@ -22,8 +22,8 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from = $_GET["from"];
-$to = $_GET["to"];
+$from = (int)$_GET["from"];
+$to = (int)$_GET["to"];
 $filelist = array();
 $fileNums = 0;
 $log = "";
@@ -59,8 +59,7 @@ echo "doing:" . $xmlfile . "<br>";
 $log = $log . "$from,$FileName,open\r\n";
 
 $arrInserString = array();
-$db_file = _FILE_DB_PALITEXT_;
-PDO_Connect("$db_file");
+PDO_Connect(_FILE_DB_PALITEXT_,_DB_USERNAME_,_DB_PASSWORD_);
 
 // 打开vri html文件并读取数据
 $pali_text_array = array();
@@ -98,10 +97,13 @@ if (($inputRow - 1) != count($pali_text_array)) {
     $log = $log . "$from, $FileName,error,文件行数不匹配 inputRow=$inputRow pali_text_array=" . count($pali_text_array) . " \r\n";
 }
 
+$query = "DELETE FROM "._TABLE_PALI_TEXT_."WHERE book=?";
+PDO_Execute($query,array($from+1));
+
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
 
-$query = "INSERT INTO pali_text ('id', 'book','paragraph','level','class','toc','text','html','lenght') VALUES (NULL, ? , ? , ? , ? , ? , ? , ?,? )";
+$query = "INSERT INTO "._TABLE_PALI_TEXT_." ( book , paragraph , level , class , toc , text , html , lenght ) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? )";
 $stmt = $PDO->prepare($query);
 foreach ($arrInserString as $oneParam) {
     if ($oneParam[3] < 100) {

+ 2 - 2
app/install/db_pali_text_export.php

@@ -34,8 +34,8 @@ if ($to == 0 || $to >= 217) {
 $book = $from + 1;
 if (($fp = fopen(_DIR_PALI_TITLE_ . "/" . $book . "_title.csv", "w")) !== false) {
     fputcsv($fp, array('id', 'book', 'par_num', 'level', 'class', 'title', 'text'));
-    PDO_Connect("" . _FILE_DB_PALITEXT_);
-    $query = "select id, book, paragraph, level, class, toc, text from pali_text where book = '$book' ";
+    PDO_Connect(_FILE_DB_PALITEXT_);
+    $query = "SELECT id, book, paragraph, level, class, toc, text from "._TABLE_PALI_TEXT_." where book = '$book' ";
     $title_data = PDO_FetchAll($query);
     foreach ($title_data as $value) {
         $value["id"] = "NULL";

+ 3 - 3
app/install/db_update_palitext.php

@@ -98,8 +98,8 @@ if ((count($arrInserString)) != count($pali_text_array) - 2) {
 $book = $from + 1;
 
 //计算段落信息,如上一段
-PDO_Connect("" . _FILE_DB_PALITEXT_);
-$query = "select * from pali_text where book = '$book' ";
+PDO_Connect(_FILE_DB_PALITEXT_,_DB_USERNAME_,_DB_PASSWORD_);
+$query = "SELECT * from "._TABLE_PALI_TEXT_." where book = '$book' ";
 $title_data = PDO_FetchAll($query);
 echo "Paragraph Count:" . count($title_data) . "<br>";
 
@@ -107,7 +107,7 @@ $paragraph_count = count($title_data);
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query = "UPDATE pali_text SET level = ? , toc = ? , chapter_len = ? , next_chapter = ?, prev_chapter=? , parent= ?  ,  chapter_strlen = ?  WHERE book=? and paragraph=?";
+$query = "UPDATE "._TABLE_PALI_TEXT_." SET level = ? , toc = ? , chapter_len = ? , next_chapter = ?, prev_chapter=? , parent= ?  ,  chapter_strlen = ?  WHERE book=? and paragraph=?";
 $stmt = $PDO->prepare($query);
 
 $paragraph_info = array();

+ 0 - 0
app/install/host=localhost;port=5432;dbname=mint;user=postgres;password=123456;


+ 4 - 7
app/install/step5.php

@@ -195,13 +195,10 @@ if (!file_exists($db[0])) {
 }
 echo "</div>";
 
-if (file_exists(_FILE_DB_PALITEXT_)) {
-    echo "Pali原文数据库已经存在<br>";
-    echo '<a href="db_insert_palitext.php" target="_blank">重新生成</a><br>';
-    echo '<a href="db_update_palitext.php" target="_blank">更新</a><br>';
-} else {
-    echo '<a href="db_insert_palitext.php">生成</a><br>';
-}
+
+echo '<a href="db_insert_palitext.php">生成</a><br>';
+echo '<a href="db_update_palitext.php" target="_blank">更新</a><br>';
+
 echo "<a href = '" . _DIR_LOG_ . "/db_update_palitext.log" . "' target='_blank'>view Log</a>"
 ?>
 </div>

+ 3 - 3
app/pali_text/function.php

@@ -5,7 +5,7 @@ require_once "../db/table.php";
 class PaliText extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_PALITEXT_, "pali_text", "", "",$redis);
+		parent::__construct(_FILE_DB_PALITEXT_, _TABLE_PALI_TEXT_, "", "",$redis);
     }
 	
 	public function getPath($book,$para){
@@ -68,7 +68,7 @@ class PaliText extends Table
 class PaliBook extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_PALITEXT_, "books", "", "",$redis);
+		parent::__construct(_FILE_DB_PALITEXT_, _TABLE_PALI_BOOK_NAME_, "", "",$redis);
     }
 	
 	public function getBookTitle($book,$para){
@@ -80,7 +80,7 @@ class PaliBook extends Table
 			}
 		}
 		*/
-		$query = "select title from books where \"book\" = ? and \"paragraph\" = ? limit 0,1";
+		$query = "SELECT title from "._TABLE_PALI_BOOK_NAME_." where book = ? and paragraph = ? limit 1";
 		$stmt = $this->dbh->prepare($query);
 		$stmt->execute(array($book, $para));
 		$book = $stmt->fetch(PDO::FETCH_ASSOC);

+ 1 - 1
app/palicanon/book_tag.php

@@ -42,7 +42,7 @@ foreach ($output as $key => $value) {
     $para = (int) $value["para"];
     $level = (int) $value["level"];
     if (count($output) < 100 || (count($output) > 100 && $level == 1)) {
-        $query = "SELECT * FROM pali_text WHERE book = ? and paragraph = ?";
+        $query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE book = ? and paragraph = ?";
         $stmt = $dbh_pali_text->prepare($query);
         $stmt->execute(array($book, $para));
         $paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);

+ 10 - 10
app/palicanon/get_chapter_children.php

@@ -8,16 +8,16 @@ try {
     $r_conn = false;
 }
 
-$dns = "" . _FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_RESRES_INDEX_;
-$dbh_res = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_RESRES_INDEX_;
+$dbh_res = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_res->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 if (isset($_GET["book"])) {
@@ -27,17 +27,17 @@ if (isset($_GET["para"])) {
     $para = (int) $_GET["para"];
 }
 
-$query = "SELECT chapter_len FROM pali_text WHERE book = ? and paragraph = ?";
+$query = "SELECT chapter_len FROM "._TABLE_PALI_TEXT_." WHERE book = ? and paragraph = ?";
 $stmt = $dbh_pali_text->prepare($query);
 $stmt->execute(array($book, $para));
 $paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
 if ($paraInfo) {
-    $query = "SELECT level FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level<8 order by level ASC limit 0,1";
+    $query = "SELECT level FROM "._TABLE_PALI_TEXT_." WHERE book = ? and (paragraph between ? and ?) and level<8 order by level ASC limit 1";
     $stmt = $dbh_pali_text->prepare($query);
     $stmt->execute(array($book, $para + 1, $para + (int) $paraInfo["chapter_len"] - 1));
     $paraMax = $stmt->fetch(PDO::FETCH_ASSOC);
     if ($paraMax) {
-        $query = "SELECT book, paragraph as para, level , toc as title FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level = ?  limit 0,1000";
+        $query = "SELECT book, paragraph as para, level , toc as title FROM "._TABLE_PALI_TEXT_." WHERE book = ? and (paragraph between ? and ?) and level = ?  limit 1000";
         $stmt = $dbh_pali_text->prepare($query);
         $stmt->execute(array($book, $para, $para + $paraInfo["chapter_len"], $paraMax["level"]));
         $paraList = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -66,7 +66,7 @@ if ($paraInfo) {
 
             #查标题
             if (isset($_GET["lang"])) {
-                $query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
+                $query = "SELECT title from "._TABLE_RES_INDEX_." where book=? and paragraph=? and language=?";
                 $stmt = $dbh_res->prepare($query);
                 $sth_title = $dbh_res->prepare($query);
                 $sth_title->execute(array($value["book"], $value["para"], $_GET["lang"]));

+ 8 - 8
app/palicanon/get_chapter_info.php

@@ -8,16 +8,16 @@ try {
     $r_conn = false;
 }
 
-$dns = "" . _FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_RESRES_INDEX_;
-$dbh_res = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_RESRES_INDEX_;
+$dbh_res = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_res->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 if (isset($_GET["book"])) {
@@ -27,7 +27,7 @@ if (isset($_GET["para"])) {
     $para = (int) $_GET["para"];
 }
 
-$query = "SELECT * FROM pali_text WHERE book = ? and paragraph = ?";
+$query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE book = ? and paragraph = ?";
 $stmt = $dbh_pali_text->prepare($query);
 $stmt->execute(array($book, $para));
 $paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -55,7 +55,7 @@ if ($paraInfo) {
 
     #查标题
     if (isset($_GET["lang"])) {
-        $query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
+        $query = "SELECT title from "._TABLE_RES_INDEX_." where book=? and paragraph=? and language=?";
         $stmt = $dbh_res->prepare($query);
         $sth_title = $dbh_res->prepare($query);
         $sth_title->execute(array($book, $para, $_GET["lang"]));

+ 4 - 2
app/path.php

@@ -79,8 +79,10 @@ define("_FILE_DB_RESRES_INDEX_", _DB_ENGIN_.":host="._DB_HOST_.";port="._DB_PORT
 define("_TABLE_RES_INDEX_","res_index");
 
 //巴利语料段落表
-//define("_FILE_DB_PALITEXT_", _DB_ENGIN_.":host="._DB_HOST_.";port="._DB_PORT_.";dbname="._DB_NAME_.";user="._DB_USERNAME_.";password="._DB_PASSWORD_.";");
-define("_FILE_DB_PALITEXT_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pali_text.db3");
+define("_FILE_DB_PALITEXT_", _DB_ENGIN_.":host="._DB_HOST_.";port="._DB_PORT_.";dbname="._DB_NAME_.";user="._DB_USERNAME_.";password="._DB_PASSWORD_.";");
+//define("_FILE_DB_PALITEXT_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pali_text.db3");
+define("_TABLE_PALI_TEXT_","pali_text");
+define("_TABLE_PALI_BOOK_NAME_","books");
 
 //单词分析表
 //define("_FILE_DB_STATISTICS_", _DB_ENGIN_.":host="._DB_HOST_.";port="._DB_PORT_.";dbname="._DB_NAME_.";user="._DB_USERNAME_.";password="._DB_PASSWORD_.";");

+ 13 - 17
app/pcdl/get_res_index.php

@@ -90,9 +90,8 @@ if ($album == -1) {
             echo "</div>";
 
             //目录
-            $db_file = _FILE_DB_PALITEXT_;
-            PDO_Connect("$db_file");
-            $query = "select * from 'pali_text' where book = '{$book}' and ( level>'0' and level<8 ) ";
+            PDO_Connect(_FILE_DB_PALITEXT_);
+            $query = "SELECT * FROM "._TABLE_PALI_TEXT_." where book = '{$book}' and ( level>'0' and level<8 ) ";
             $Fetch_Toc = PDO_FetchAll($query);
             $iFetchToc = count($Fetch_Toc);
             if ($iFetchToc > 0) {
@@ -134,9 +133,9 @@ if ($album == -1) {
         }
     } else {
         //查书中的一个段
-        $db_file = _FILE_DB_PALITEXT_;
-        PDO_Connect("$db_file");
-        $query = "select text from 'pali_text' where book= '{$book}' and  paragraph= '{$paragraph}' ";
+
+        PDO_Connect(_FILE_DB_PALITEXT_);
+        $query = "SELECT text from "._TABLE_PALI_TEXT_." where book= '{$book}' and  paragraph= '{$paragraph}' ";
         $res_title = PDO_FetchOne($query);
         echo "<div id='album_info_head'>";
         echo "<h2>$res_title</h2>";
@@ -149,8 +148,8 @@ if ($album == -1) {
         echo "</div>";
         echo "</div>";
 
-        PDO_Connect("" . _FILE_DB_RESRES_INDEX_);
-        $query = "select resindex.id,resindex.title,resindex.type,resindex.album,author.name from 'index' as resindex LEFT JOIN author ON resindex.author = author.id where resindex.book='$book' and resindex.paragraph=$paragraph and resindex.type<>7 group by resindex.album";
+        PDO_Connect(_FILE_DB_RESRES_INDEX_);
+        $query = "SELECT resindex.id,resindex.title,resindex.type,resindex.album,author.name from "._TABLE_RES_INDEX_." as resindex LEFT JOIN author ON resindex.author = author.id where resindex.book='$book' and resindex.paragraph=$paragraph and resindex.type<>7 group by resindex.album";
         $Fetch = PDO_FetchAll($query);
         $iFetch = count($Fetch);
         if ($iFetch > 0) {
@@ -188,11 +187,9 @@ if ($album == -1) {
         }
 
         //目录
-        $db_file = _FILE_DB_PALITEXT_;
-        PDO_Connect("$db_file");
-        $query = "select * from 'pali_text' where book = '{$book}' and level>'0' and level<8 and paragraph>=$paragraph ";
-
-        $Fetch_Toc = PDO_FetchAll($query);
+        PDO_Connect(_FILE_DB_PALITEXT_);
+        $query = "SELECT * from "._TABLE_RES_INDEX_." where book = ? and level>'0' and level<8 and paragraph >= ? ";
+        $Fetch_Toc = PDO_FetchAll($query,array($book,$paragraph));
         $iFetchToc = count($Fetch_Toc);
         if ($iFetchToc > 1) {
             if ($Fetch_Toc[1]["level"] > $Fetch_Toc[0]["level"]) {
@@ -286,9 +283,8 @@ if ($album == -1) {
                 case 1:
                 case 2:
                 case 6:
-                    $db_file = _FILE_DB_PALITEXT_;
-                    PDO_Connect("$db_file");
-                    $query = "select * from 'pali_text' where book = '{$book}' and level>'0' and level<8 ";
+                    PDO_Connect(_FILE_DB_PALITEXT_);
+                    $query = "select * from "._TABLE_PALI_TEXT_." where book = '{$book}' and level>'0' and level<8 ";
                     break;
                 case 3:
                     $db_file = '../' . $album_file_name;
@@ -401,7 +397,7 @@ if ($album == -1) {
                 case 2:
                 case 6:
                     PDO_Connect(_FILE_DB_PALITEXT_);
-                    $query = "select * from 'pali_text' where book = '{$book}' and level>'0' and level<8 and paragraph>=$paragraph ";
+                    $query = "select * from "._TABLE_PALI_TEXT_." where book = '{$book}' and level>'0' and level<8 and paragraph>=$paragraph ";
                     break;
                 case 3:
                     $db_file = "../{$album_file_name}";

+ 2 - 2
app/pcdl/pc_get_book_index.php

@@ -11,9 +11,9 @@ echo $outXml;
 
 //open database
 PDO_Connect(_FILE_DB_PALITEXT_);
-$query = "select * FROM pali_text where \"book\"=" . $PDO->quote($currBook);
+$query = "SELECT * FROM "._TABLE_PALI_TEXT_." where book = ?";
 
-$Fetch = PDO_FetchAll($query);
+$Fetch = PDO_FetchAll($query,array($currBook));
 $iFetch = count($Fetch);
 
 if ($iFetch > 0) {

+ 5 - 5
app/pcdl/pc_get_book_res.php

@@ -46,20 +46,20 @@ switch ($res_type) {
 }
 //open database
 //echo "$db_file";
-PDO_Connect("$db_file");
+PDO_Connect($db_file);
 switch ($res_type) {
     case "wbw":
         if ($author == "templet") {
-            $query = "SELECT * FROM \"main\" WHERE \"book\" = " . $PDO->quote($currBook) . " AND \"paragraph\" = " . $PDO->quote($currParagraph) . "  ORDER BY vri ";
+            $query = "SELECT * FROM \"main\" WHERE book = " . $PDO->quote($currBook) . " AND paragraph = " . $PDO->quote($currParagraph) . "  ORDER BY vri ";
         } else {
-            $query = "SELECT * FROM \"main\" WHERE \"book\" = " . $PDO->quote($currBook) . " AND \"paragraph\" = " . $PDO->quote($currParagraph) . " AND \"language\" = " . $PDO->quote($language) . " AND \"author\" = " . $PDO->quote($author) . " AND \"editor\" = " . $PDO->quote($editor) . " AND \"edition\" = " . $PDO->quote($edition) . " AND \"subver\" = " . $PDO->quote($subver) . "  ORDER BY vri ";
+            $query = "SELECT * FROM \"main\" WHERE book = " . $PDO->quote($currBook) . " AND paragraph = " . $PDO->quote($currParagraph) . " AND \"language\" = " . $PDO->quote($language) . " AND \"author\" = " . $PDO->quote($author) . " AND \"editor\" = " . $PDO->quote($editor) . " AND \"edition\" = " . $PDO->quote($edition) . " AND \"subver\" = " . $PDO->quote($subver) . "  ORDER BY vri ";
         }
         break;
     case "heading":
         if ($author == "templet") {
-            $query = "SELECT * FROM \"pali_text\" WHERE \"book\" = " . $PDO->quote($currBook) . " AND \"paragraph\" = " . $PDO->quote($currParagraph);
+            $query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE book = " . $PDO->quote($currBook) . " AND paragraph = " . $PDO->quote($currParagraph);
         } else {
-            $query = "SELECT * FROM \"pali_text\" WHERE \"book\" = " . $PDO->quote($currBook) . " AND \"par_num\" = " . $PDO->quote($currParagraph) . " AND \"language\" = " . $PDO->quote($language) . " AND \"author\" = " . $PDO->quote($author) . " AND \"editor\" = " . $PDO->quote($editor) . " AND \"edition\" = " . $PDO->quote($edition) . " AND \"subver\" = " . $PDO->quote($subver);
+            $query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE book = " . $PDO->quote($currBook) . " AND par_num = " . $PDO->quote($currParagraph) . " AND \"language\" = " . $PDO->quote($language) . " AND \"author\" = " . $PDO->quote($author) . " AND \"editor\" = " . $PDO->quote($editor) . " AND \"edition\" = " . $PDO->quote($edition) . " AND \"subver\" = " . $PDO->quote($subver);
         }
         break;
     case "translate":

+ 5 - 5
app/pcdl/search.php

@@ -35,9 +35,9 @@ switch ($op) {
         }
 
         //查标题
-        $query = "select count(*) from 'index'  where  title_en like '%$word%' or title like '%$word%'";
+        $query = "select count(*) from "._TABLE_RES_INDEX_."  where  title_en like '%$word%' or title like '%$word%'";
         $count = PDO_FetchOne($query);
-        $query = "select * from 'index'  where  title_en like '%$word%' or title like '%$word%' limit 0,20";
+        $query = "select * from "._TABLE_RES_INDEX_."  where  title_en like '%$word%' or title like '%$word%' limit 0,20";
         $Fetch = PDO_FetchAll($query);
         $iFetch = count($Fetch);
         if ($iFetch > 0) {
@@ -69,8 +69,8 @@ switch ($op) {
                 //循环查找父标题 得到整条路径
 
                 while ($parent > -1) {
-                    $query = "select * from pali_text where \"book\" = '{$bookid}' and \"paragraph\" = '{$parent}' limit 0,1";
-                    $FetParent = PDO_FetchAll($query);
+                    $query = "SELECT * FROM "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                    $FetParent = PDO_FetchAll($query,array($bookid,$parent));
                     if ($deep > 0) {
                         $path = "{$FetParent[0]["toc"]}>{$path}";
                     }
@@ -97,7 +97,7 @@ switch ($op) {
         $query = "SELECT count(*) from "._TABLE_RES_INDEX_." where tag like '%$word%'";
         $count = PDO_FetchOne($query);
 
-        $query = "SELECT * from "._TABLE_RES_INDEX_." where tag like '%$word%' limit 0,10";
+        $query = "SELECT * from "._TABLE_RES_INDEX_." where tag like '%$word%' limit 10";
         $Fetch = PDO_FetchAll($query);
         $iFetch = count($Fetch);
         if ($iFetch > 0) {

+ 3 - 3
app/public/function.php

@@ -69,8 +69,8 @@ function _get_book_path($index)
 function _get_para_path($book, $paragraph)
 {
 
-    $dns = "" . _FILE_DB_PALITEXT_;
-    $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dns = _FILE_DB_PALITEXT_;
+    $dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     $path = "";
@@ -79,7 +79,7 @@ function _get_para_path($book, $paragraph)
     $sFirstParentTitle = "";
     //循环查找父标题 得到整条路径
     while ($parent > -1) {
-        $query = "select * from pali_text where \"book\" = ? and \"paragraph\" = ? limit 0,1";
+        $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
         $stmt = $dbh->prepare($query);
         $stmt->execute(array($book, $parent));
         $FetParent = $stmt->fetch(PDO::FETCH_ASSOC);

+ 5 - 5
app/reader/get_para.php

@@ -65,8 +65,8 @@ $paraBegin=0;
 $paraEnd=0;
 
 PDO_Connect(_FILE_DB_PALITEXT_);
-			$query = "SELECT level , parent, chapter_len,chapter_strlen FROM 'pali_text'  WHERE book= ? AND paragraph= ?";
-			$FetchParInfo = PDO_FetchRow($query, array($_book, $_para));
+$query = "SELECT level , parent, chapter_len,chapter_strlen FROM "._TABLE_PALI_TEXT_."  WHERE book= ? AND paragraph= ?";
+$FetchParInfo = PDO_FetchRow($query, array($_book, $_para));
 if ($FetchParInfo) {
     switch ($_view) {
         case 'chapter':
@@ -78,7 +78,7 @@ if ($FetchParInfo) {
 			}
             else{
 				$paraBegin = $FetchParInfo["parent"];
-				$query = "SELECT  level , parent, chapter_len,chapter_strlen FROM 'pali_text'  WHERE book= ? AND paragraph= ?";
+				$query = "SELECT  level , parent, chapter_len,chapter_strlen FROM "._TABLE_PALI_TEXT_."  WHERE book= ? AND paragraph= ?";
 				$FetchParInfo = PDO_FetchRow($query, array($_book, $paraBegin));
             	$paraEnd = $paraBegin + $FetchParInfo["chapter_len"] - 1;
 			}
@@ -99,7 +99,7 @@ if ($FetchParInfo) {
     }
 
     //获取下级目录
-    $query = "SELECT level,paragraph,toc FROM 'pali_text'  WHERE book= ? AND (paragraph BETWEEN ?AND ? ) AND level < 8 ";
+    $query = "SELECT level,paragraph,toc FROM "._TABLE_PALI_TEXT_."  WHERE book= ? AND (paragraph BETWEEN ?AND ? ) AND level < 8 ";
     $output["toc"] = PDO_FetchAll($query, array($_book, $paraBegin, $paraEnd));
 
     if ($FetchParInfo["chapter_strlen"] > _MAX_CHAPTER_LEN_ && $_view === "chapter" && count($output["toc"]) > 1) {
@@ -118,7 +118,7 @@ if ($FetchParInfo) {
 
     PDO_Connect(_FILE_DB_PALI_SENTENCE_);
 
-    $query = "SELECT book,paragraph,begin, end FROM 'pali_sent' WHERE book= ? AND (paragraph BETWEEN ?AND ? ) ";
+    $query = "SELECT book,paragraph,begin, end FROM "._TABLE_PALI_TEXT_." WHERE book= ? AND (paragraph BETWEEN ?AND ? ) ";
     $sent_list = PDO_FetchAll($query, array($_book, $paraBegin, $paraEnd));
     $output["sentences"] = $sent_list;
     echo json_encode($output, JSON_UNESCAPED_UNICODE);

+ 4 - 4
app/reader/get_para1.php

@@ -77,7 +77,7 @@ $paraBegin=0;
 $paraEnd=0;
 
 PDO_Connect(_FILE_DB_PALITEXT_);
-$query = "SELECT level , parent, chapter_len,chapter_strlen FROM 'pali_text'  WHERE book= ? AND paragraph= ?";
+$query = "SELECT level , parent, chapter_len,chapter_strlen FROM "._TABLE_PALI_TEXT_."  WHERE book= ? AND paragraph= ?";
 $FetchParInfo = PDO_FetchRow($query, array($_book, $_para));
 if ($FetchParInfo) {
     switch ($_view) {
@@ -92,7 +92,7 @@ if ($FetchParInfo) {
             else{
 				#不是标题,加载所在段落
 				$paraBegin = $FetchParInfo["parent"];
-				$query = "SELECT  level , parent, chapter_len,chapter_strlen FROM 'pali_text'  WHERE book= ? AND paragraph= ?";
+				$query = "SELECT  level , parent, chapter_len,chapter_strlen FROM "._TABLE_PALI_TEXT_."  WHERE book= ? AND paragraph= ?";
 				$FetchParInfo = PDO_FetchRow($query, array($_book, $paraBegin));
             	$paraEnd = $paraBegin + $FetchParInfo["chapter_len"] - 1;
 			}
@@ -110,7 +110,7 @@ if ($FetchParInfo) {
     }
 
     //获取下级目录
-    $query = "SELECT level,paragraph,toc FROM 'pali_text'  WHERE book= ? AND (paragraph BETWEEN ?AND ? ) AND level < 8 ";
+    $query = "SELECT level,paragraph,toc FROM "._TABLE_PALI_TEXT_."  WHERE book= ? AND (paragraph BETWEEN ?AND ? ) AND level < 8 ";
     $toc = PDO_FetchAll($query, array($_book, $paraBegin, $paraEnd));
 	if(count($toc)>0){
 		$output["title"] = $toc[0]["toc"];
@@ -153,7 +153,7 @@ if ($FetchParInfo) {
 
     PDO_Connect(_FILE_DB_PALI_SENTENCE_);
 
-    $query = "SELECT book,paragraph,begin, end FROM 'pali_sent' WHERE book= ? AND (paragraph BETWEEN ? AND ? ) ";
+    $query = "SELECT book,paragraph,begin, end FROM pali_sent WHERE book= ? AND (paragraph BETWEEN ? AND ? ) ";
     $sent_list = PDO_FetchAll($query, array($_book, $paraBegin, $paraEnd));
 	$iCurrPara=0;
 	$output["sent_list"] = $sent_list;

+ 4 - 4
app/search/bold_search.php

@@ -167,8 +167,8 @@ switch ($op) {
                     if (strlen($pali) > 1) {
                         echo "<div class='mean'>$pali</div>";
                     } else {
-                        PDO_Connect(_FILE_DB_PALITEXT_);
-                        $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
+                        //PDO_Connect(_FILE_DB_PALITEXT_);
+                        $query = "select * from "._TABLE_PALI_TEXT_." where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
                         $FetchPaliText = PDO_FetchAll($query);
                         $countPaliText = count($FetchPaliText);
                         if ($countPaliText > 0) {
@@ -324,7 +324,7 @@ switch ($op) {
                             echo "<div class='mean'>$pali</div>";
                         } else {
                             PDO_Connect(_FILE_DB_PALITEXT_);
-                            $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
+                            $query = "select * from "._TABLE_PALI_TEXT_." where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
                             $FetchPaliText = PDO_FetchAll($query);
                             $countPaliText = count($FetchPaliText);
                             if ($countPaliText > 0) {
@@ -335,7 +335,7 @@ switch ($op) {
                                     $deep = 0;
                                     $sFirstParentTitle = "";
                                     while ($parent > -1) {
-                                        $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
+                                        $query = "select * from "._TABLE_PALI_TEXT_." where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
                                         $FetParent = PDO_FetchAll($query);
                                         if ($sFirstParentTitle == "") {
                                             $sFirstParentTitle = $FetParent[0]["toc"];

+ 11 - 10
app/search/paliword_sc.php

@@ -43,11 +43,12 @@ if (isset($_GET["page"])) {
 
 if (count($arrWordList) > 1) {
 	# 查询多个词
+	$out_data = array();
     PDO_Connect(_FILE_DB_PALITEXT_);
     # 首先精确匹配
     $words = implode(" ", $arrWordList);
-    $query = "SELECT book,paragraph, text FROM pali_text WHERE text like ?  LIMIT ? , ?";
-    $Fetch1 = PDO_FetchAll($query, array("%{$words}%", $_page * $_pagesize, $_pagesize));
+    $query = "SELECT book,paragraph, text FROM "._TABLE_PALI_TEXT_." WHERE text like ?  LIMIT ? OFFSET ?";
+    $Fetch1 = PDO_FetchAll($query, array("%{$words}%", $_pagesize, $_page * $_pagesize));
 
     foreach ($Fetch1 as $key => $value) {
         # code...
@@ -101,8 +102,8 @@ if ($countWord == 0) {
     #没查到 模糊查询
 
     PDO_Connect(_FILE_DB_PALITEXT_);
-    $query = "SELECT book,paragraph, text FROM pali_text WHERE text like ?  LIMIT ? , ?";
-    $Fetch = PDO_FetchAll($query, array("%{$word}%", $_page * $_pagesize, $_pagesize));
+    $query = "SELECT book,paragraph, text FROM "._TABLE_PALI_TEXT_." WHERE text like ?  LIMIT ? OFFSET ?";
+    $Fetch = PDO_FetchAll($query, array("%{$word}%", $_pagesize, $_page * $_pagesize));
 
     $result["data"] = $Fetch;
     exit;
@@ -209,8 +210,8 @@ $query = "SELECT count(*) from (SELECT book FROM word WHERE \"wordindex\" in $st
 $result["record_count"] = PDO_FetchOne($query);
 $result["time"][] = array("event" => "查询记录数", "time" => microtime(true) - $_start);
 
-$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT ?,?";
-$Fetch = PDO_FetchAll($query,array($_page * $_pagesize, $_pagesize));
+$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT ? OFFSET ?";
+$Fetch = PDO_FetchAll($query,array($_pagesize , $_page * $_pagesize));
 $result["time"][] = array("event" => "查询结束", "time" => microtime(true) - $_start);
 $out_data = array();
 
@@ -240,8 +241,8 @@ if ($iFetch > 0) {
             $path_1 = $path_1 . $c3 . ">";
         }
         $path_1 = $path_1 . "《{$bookname}》>";
-        $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,1";
-        $FetchPaliText = PDO_FetchAll($query);
+        $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+        $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph));
         $countPaliText = count($FetchPaliText);
         if ($countPaliText > 0) {
             $path = "";
@@ -250,8 +251,8 @@ if ($iFetch > 0) {
             $sFirstParentTitle = "";
             //循环查找父标题 得到整条路径
             while ($parent > -1) {
-                $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
-                $FetParent = PDO_FetchAll($query);
+                $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                $FetParent = PDO_FetchAll($query,array($book,$parent));
                 $path = "{$FetParent[0]["toc"]}>{$path}";
                 if ($sFirstParentTitle == "") {
                     $sFirstParentTitle = $FetParent[0]["toc"];

+ 9 - 9
app/search/paliword_search.php

@@ -69,7 +69,7 @@ switch ($op) {
                 }
                 $strQuery = substr($strQuery, 0, -3);
                 PDO_Connect(_FILE_DB_PALITEXT_);
-                $query = "SELECT book,paragraph, html FROM pali_text WHERE {$strQuery}  LIMIT 0,20";
+                $query = "SELECT book,paragraph, html FROM _TABLE_PALI_TEXT_ WHERE {$strQuery}  LIMIT 20";
                 $Fetch = PDO_FetchAll($query);
                 echo "<div>$query</div>";
                 $iFetch = count($Fetch);
@@ -192,8 +192,8 @@ switch ($op) {
                         $path_1 = $path_1 . $c3 . ">";
                     }
                     $path_1 = $path_1 . "《{$bookname}》>";
-                    $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,1";
-                    $FetchPaliText = PDO_FetchAll($query);
+                    $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                    $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph));
                     $countPaliText = count($FetchPaliText);
                     if ($countPaliText > 0) {
                         $path = "";
@@ -202,8 +202,8 @@ switch ($op) {
                         $sFirstParentTitle = "";
                         //循环查找父标题 得到整条路径
                         while ($parent > -1) {
-                            $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
-                            $FetParent = PDO_FetchAll($query);
+                            $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                            $FetParent = PDO_FetchAll($query,array($book,$parent));
                             $path = "{$FetParent[0]["toc"]}>{$path}";
                             if ($sFirstParentTitle == "") {
                                 $sFirstParentTitle = $FetParent[0]["toc"];
@@ -302,8 +302,8 @@ switch ($op) {
                         echo "<div class='book' ><span style='font-size:110%;font-weight:700;'>《{$bookname}》</span> <tag>$c1</tag> <tag>$c2</tag> </div>";
                         echo "<div class='mean'>$paliword</div>";
 
-                        $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
-                        $FetchPaliText = PDO_FetchAll($query);
+                        $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 20";
+                        $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph));
                         $countPaliText = count($FetchPaliText);
                         if ($countPaliText > 0) {
                             for ($iPali = 0; $iPali < $countPaliText; $iPali++) {
@@ -312,8 +312,8 @@ switch ($op) {
                                 $deep = 0;
                                 $sFirstParentTitle = "";
                                 while ($parent > -1) {
-                                    $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
-                                    $FetParent = PDO_FetchAll($query);
+                                    $query = "select * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                                    $FetParent = PDO_FetchAll($query,array($book,$parent));
                                     if ($sFirstParentTitle == "") {
                                         $sFirstParentTitle = $FetParent[0]["toc"];
                                     }

+ 9 - 9
app/search/search.php

@@ -155,7 +155,7 @@ switch ($op) {
                 }
                 $strQuery = substr($strQuery, 0, -3);
                 PDO_Connect(_FILE_DB_PALITEXT_);
-                $query = "SELECT book,paragraph, html FROM pali_text WHERE {$strQuery}  LIMIT 0,20";
+                $query = "SELECT book,paragraph, html FROM "._TABLE_PALI_TEXT_." WHERE {$strQuery}  LIMIT 20";
                 $Fetch = PDO_FetchAll($query);
                 echo "<div>$query</div>";
                 $iFetch = count($Fetch);
@@ -314,8 +314,8 @@ switch ($op) {
                         $path_1 = $path_1 . $c3 . ">";
                     }
                     $path_1 = $path_1 . "《{$bookname}》>";
-                    $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,1";
-                    $FetchPaliText = PDO_FetchAll($query);
+                    $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                    $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph));
                     $countPaliText = count($FetchPaliText);
                     if ($countPaliText > 0) {
                         $path = "";
@@ -324,8 +324,8 @@ switch ($op) {
                         $sFirstParentTitle = "";
                         //循环查找父标题 得到整条路径
                         while ($parent > -1) {
-                            $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
-                            $FetParent = PDO_FetchAll($query);
+                            $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                            $FetParent = PDO_FetchAll($query,array($book,$parent));
                             $path = "{$FetParent[0]["toc"]}>{$path}";
                             if ($sFirstParentTitle == "") {
                                 $sFirstParentTitle = $FetParent[0]["toc"];
@@ -418,8 +418,8 @@ switch ($op) {
                         echo "<div class='dict'>《{$bookname}》 $c1 $c2 </div>";
                         echo "<div class='mean'>$paliword</div>";
 
-                        $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
-                        $FetchPaliText = PDO_FetchAll($query);
+                        $query = "select * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 20";
+                        $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph));
                         $countPaliText = count($FetchPaliText);
                         if ($countPaliText > 0) {
                             for ($iPali = 0; $iPali < $countPaliText; $iPali++) {
@@ -428,8 +428,8 @@ switch ($op) {
                                 $deep = 0;
                                 $sFirstParentTitle = "";
                                 while ($parent > -1) {
-                                    $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
-                                    $FetParent = PDO_FetchAll($query);
+                                    $query = "select * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                                    $FetParent = PDO_FetchAll($query,array($book,$parent));
                                     if ($sFirstParentTitle == "") {
                                         $sFirstParentTitle = $FetParent[0]["toc"];
                                     }

+ 8 - 8
app/search/title_search.php

@@ -215,12 +215,12 @@ switch ($op) {
                     $path = _get_para_path($book, $paragraph);
                     echo $path_1 . $path;
 
-                    $query = "select chapter_len from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,1";
-                    $chapter_len = PDO_FetchAll($query);
+                    $query = "select chapter_len from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                    $chapter_len = PDO_FetchAll($query,array($book,$paragraph));
                     $chapter_len = $chapter_len[0]["chapter_len"];
 
-                    $query = "select text from pali_text where \"book\" = '{$book}' and (\"paragraph\" > '{$paragraph}' and \"paragraph\" <= '" . ($paragraph + $chapter_len) . "') limit 0,3";
-                    $FetchPaliText = PDO_FetchAll($query);
+                    $query = "select text from "._TABLE_PALI_TEXT_." where book = ? and (paragraph > ? and paragraph <= ?) limit 3";
+                    $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph,($paragraph + $chapter_len)));
                     $paliContent = "";
                     foreach ($FetchPaliText as $text) {
                         $paliContent .= $text["text"];
@@ -301,8 +301,8 @@ switch ($op) {
                         echo "<div class='dict'>《{$bookname}》 $c1 $c2 </div>";
                         echo "<div class='mean'>$paliword</div>";
 
-                        $query = "SELECT * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
-                        $FetchPaliText = PDO_FetchAll($query);
+                        $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 20";
+                        $FetchPaliText = PDO_FetchAll($query,array($book,$paragraph));
                         $countPaliText = count($FetchPaliText);
                         if ($countPaliText > 0) {
                             for ($iPali = 0; $iPali < $countPaliText; $iPali++) {
@@ -311,8 +311,8 @@ switch ($op) {
                                 $deep = 0;
                                 $sFirstParentTitle = "";
                                 while ($parent > -1) {
-                                    $query = "SELECT * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
-                                    $FetParent = PDO_FetchAll($query);
+                                    $query = "SELECT * from "._TABLE_PALI_TEXT_." where book = ? and paragraph = ? limit 1";
+                                    $FetParent = PDO_FetchAll($query,array($book,$parent));
                                     if ($sFirstParentTitle == "") {
                                         $sFirstParentTitle = $FetParent[0]["toc"];
                                     }

+ 2 - 2
app/studio/pc_get_book_index.php

@@ -12,9 +12,9 @@ echo "<index>";
 
 //open database
 PDO_Connect(_FILE_DB_PALITEXT_);
-$query = "select * FROM pali_text where \"book\"=" . $PDO->quote($currBook);
+$query = "SELECT * FROM "._TABLE_PALI_TEXT_." where book = ? ";
 
-$Fetch = PDO_FetchAll($query);
+$Fetch = PDO_FetchAll($query,array($currBook));
 $iFetch = count($Fetch);
 
 if ($iFetch > 0) {

+ 1 - 1
app/studio/pc_get_book_res.php

@@ -46,7 +46,7 @@ switch ($res_type) {
 }
 //open database
 //echo "$db_file";
-PDO_Connect("$db_file");
+PDO_Connect($db_file);
 switch ($res_type) {
     case "wbw":
         if ($author == "templet") {

+ 1 - 1
app/studio/pc_get_pali_text.php

@@ -15,7 +15,7 @@ echo "book:$get_book<br />";
 //open database
 PDO_Connect(_FILE_DB_PALITEXT_);
 
-$query = "SELECT paragraph,html FROM pali_text WHERE book = ?";
+$query = "SELECT paragraph,html FROM "._TABLE_PALI_TEXT_." WHERE book = ?";
 $Fetch = PDO_FetchAll($query, array($get_book));
 $iFetch = count($Fetch);
 if ($iFetch > 0) {

+ 4 - 4
app/studio/project.php

@@ -57,7 +57,7 @@ switch ($op) {
         $strQueryParaList = str_replace(",", "','", $paraList);
         $strQueryParaList = "('" . $strQueryParaList . "')";
         PDO_Connect(_FILE_DB_PALITEXT_);
-        $query = "SELECT sum(lenght) as sum_str FROM pali_text WHERE \"book\" = " . $PDO->quote($res_book) . " AND (\"paragraph\" in {$strQueryParaList} ) ";
+        $query = "SELECT sum(lenght) as sum_str FROM "._TABLE_PALI_TEXT_." WHERE book = " . $PDO->quote($res_book) . " AND (paragraph in {$strQueryParaList} ) ";
         $Fetch = PDO_FetchAll($query);
         if (count($Fetch) > 0) {
             if ($Fetch[0]["sum_str"] > 15000) {
@@ -131,7 +131,7 @@ switch ($op) {
                             //获取段落层级和标题
                             $para_title = array();
                             PDO_Connect(_FILE_DB_PALITEXT_);
-                            $query = "SELECT * FROM pali_text WHERE  book  = " . $PDO->quote($res_book) . " AND ( paragraph  in {$strQueryParaList} ) AND level>0 AND level<9";
+                            $query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE  book  = " . $PDO->quote($res_book) . " AND ( paragraph  in {$strQueryParaList} ) AND level>0 AND level<9";
                             $sth = $PDO->prepare($query);
                             $sth->execute();
                             while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
@@ -467,7 +467,7 @@ switch ($op) {
                     case "1": //pali text
                         {
                             PDO_Connect(_FILE_DB_PALITEXT_);
-                            $query = "SELECT * FROM pali_text WHERE \"book\" = " . $PDO->quote($res_book) . " AND (\"paragraph\" in {$strQueryParaList} ) ";
+                            $query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE \"book\" = " . $PDO->quote($res_book) . " AND (\"paragraph\" in {$strQueryParaList} ) ";
 
                             $sth = $PDO->prepare($query);
                             $sth->execute();
@@ -665,7 +665,7 @@ switch ($op) {
                             //获取段落层级和标题
                             $para_title = array();
                             PDO_Connect(_FILE_DB_PALITEXT_);
-                            $query = "SELECT * FROM pali_text WHERE  book\" = " . $PDO->quote($res_book) . " AND (\"paragraph\" in {$strQueryParaList} ) AND level>0 AND level<9";
+                            $query = "SELECT * FROM "._TABLE_PALI_TEXT_." WHERE  book\" = " . $PDO->quote($res_book) . " AND (\"paragraph\" in {$strQueryParaList} ) AND level>0 AND level<9";
                             $sth = $PDO->prepare($query);
                             $sth->execute();
                             while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {

+ 2 - 2
app/term/related_para.php

@@ -49,8 +49,8 @@ if (count($fetch) > 0) {
 
     foreach ($aBookid as $bookkey => $bookvalue) {
         # code...
-        $query = "select * from books where id=" . $bookkey;
-        $book_list[] = PDO_FetchRow($query);
+        $query = "SELECT * from "._TABLE_PALI_BOOK_NAME_." where id = ? ";
+        $book_list[] = PDO_FetchRow($query,array($bookkey));
     }
     $result["book_list"] = $book_list;
 

+ 9 - 9
app/upgrade/upgrade_pali_toc.php

@@ -5,20 +5,20 @@ require_once '../path.php';
 $redis = new redis();
 $r_conn = $redis->connect('127.0.0.1', 6379);
 
-$dns = "" . _FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_SENTENCE_;
-$dbh_sent = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_SENTENCE_;
+$dbh_sent = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_PALI_SENTENCE_;
-$dbh_pali_sent = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALI_SENTENCE_;
+$dbh_pali_sent = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 $valid_book = array();
@@ -110,7 +110,7 @@ $sth_toc = $dbh_toc->prepare($query);
 foreach ($valid_book as $key => $book) {
     echo "doing chapter in book " . $book["book"] . "\n";
     # code...
-    $query = "SELECT paragraph , chapter_len from pali_text where level < 8 and book = ?";
+    $query = "SELECT paragraph , chapter_len from "._TABLE_PALI_TEXT_." where level < 8 and book = ?";
     $stmt = $dbh_pali_text->prepare($query);
     $stmt->execute(array($book["book"]));
     $result_chapter = $stmt->fetchAll(PDO::FETCH_ASSOC);

+ 7 - 7
app/uwbw/create_wbw.php

@@ -47,12 +47,12 @@ $output["para"]=$_para;
 $output["channel"]=$_channel;
 
 //判断单词数量 太大的不能加载
-PDO_Connect(""._FILE_DB_PALITEXT_);
-$params = array(1, 21, 63, 171);
-/*  创建一个填充了和params相同数量占位符的字符串 */
+PDO_Connect(_FILE_DB_PALITEXT_);
+
+/*  创建一个填充了和 _para 相同数量占位符的字符串 */
 $place_holders = implode(',', array_fill(0, count($_para), '?'));
 
-$query = "SELECT sum(lenght) FROM pali_text WHERE   paragraph IN ($place_holders) AND book = ?";
+$query = "SELECT sum(lenght) FROM _TABLE_PALI_TEXT_ WHERE   paragraph IN ($place_holders) AND book = ?";
 $param_letter = $_para;
 $param_letter[] = $_book;
 $sum_len = PDO_FetchOne($query,$param_letter);
@@ -67,7 +67,7 @@ if($sum_len>MAX_LETTER){
 
 # 查询数据库是否有数据,没有就建立
 // 查询逐词解析库
-PDO_Connect(""._FILE_DB_USER_WBW_);
+//PDO_Connect(_FILE_DB_USER_WBW_);
 
 //模板库
 PDO_Connect(_FILE_DB_PALICANON_TEMPLET_);
@@ -75,8 +75,8 @@ $dbh_tpl = $PDO;
 $dbh_tpl->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 #用户逐词译库
-$db_wbw = ""._FILE_DB_USER_WBW_;
-$dbh_wbw= new PDO($db_wbw, "", "");
+$db_wbw = _FILE_DB_USER_WBW_;
+$dbh_wbw= new PDO($db_wbw, _DB_USERNAME_, _DB_PASSWORD_);
 $dbh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 $channelClass = new Channal(redis_connect());
 $channelInfo = $channelClass->getChannal($_channel);