|
|
@@ -8,7 +8,7 @@ function update_historay($sent_id, $user_id, $text, $landmark)
|
|
|
{
|
|
|
# 更新historay
|
|
|
PDO_Connect("" . _FILE_DB_USER_SENTENCE_HISTORAY_);
|
|
|
- $query = "INSERT INTO sent_historay (sent_id, user_id, text, date, landmark) VALUES (? , ? , ? , ? , ? )";
|
|
|
+ $query = "INSERT INTO "._TABLE_SENTENCE_HISTORAY_." (sent_uid, user_uid, content, date, landmark) VALUES (? , ? , ? , ? , ? )";
|
|
|
$stmt = PDO_Execute($query,
|
|
|
array($sent_id,
|
|
|
$user_id,
|
|
|
@@ -30,13 +30,13 @@ class SentPr{
|
|
|
private $dbh_sent;
|
|
|
private $redis;
|
|
|
public function __construct($redis=false) {
|
|
|
- $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, "", "",array(PDO::ATTR_PERSISTENT=>true));
|
|
|
+ $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
|
|
|
$this->dbh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
|
|
$this->redis=$redis;
|
|
|
}
|
|
|
public function getNewPrNumber($book,$para,$begin,$end,$channel){
|
|
|
if ($this->dbh_sent) {
|
|
|
- $query = "SELECT count(*) as ct FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? and status=1 ";
|
|
|
+ $query = "SELECT count(*) as ct FROM "._TABLE_SENTENCE_PR_." WHERE book_id = ? and paragraph= ? and word_start=? and word_end=? and channel_uid=? and status=1 ";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
$stmt->execute(array($book,$para,$begin,$end,$channel));
|
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
@@ -53,7 +53,7 @@ class SentPr{
|
|
|
}
|
|
|
public function getAllPrNumber($book,$para,$begin,$end,$channel){
|
|
|
if ($this->dbh_sent) {
|
|
|
- $query = "SELECT count(*) as ct FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? ";
|
|
|
+ $query = "SELECT count(*) as ct FROM "._TABLE_SENTENCE_PR_." WHERE book_id = ? and paragraph= ? and word_start=? and word_end=? and channel_uid=? ";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
$stmt->execute(array($book,$para,$begin,$end,$channel));
|
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
@@ -71,7 +71,7 @@ class SentPr{
|
|
|
|
|
|
public function getPrData($book,$para,$begin,$end,$channel){
|
|
|
if ($this->dbh_sent) {
|
|
|
- $query = "SELECT id,book,paragraph,begin,end,channel,text,editor,modify_time FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? and status=1 limit 0,100";
|
|
|
+ $query = "SELECT id,book_id as book,paragraph,word_start as begin,word_end as end,channel_uid as channel,content as text,editor_uid as editor,modify_time FROM "._TABLE_SENTENCE_PR_." WHERE book_id = ? and paragraph= ? and word_start=? and word_end=? and channel_uid=? and status=1 limit 100";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
$stmt->execute(array($book,$para,$begin,$end,$channel));
|
|
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
@@ -88,7 +88,7 @@ class SentPr{
|
|
|
}
|
|
|
public function getPrDataById($id){
|
|
|
if ($this->dbh_sent) {
|
|
|
- $query = "SELECT id,book,paragraph,begin,end,channel,text,editor,modify_time FROM sent_pr WHERE id = ? ";
|
|
|
+ $query = "SELECT id,book_id as book,paragraph,word_start as begin,word_end as end,channel_uid as channel,content as text,editor_uid as editor,modify_time FROM "._TABLE_SENTENCE_PR_." WHERE id = ? ";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
$stmt->execute(array($id));
|
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
@@ -106,7 +106,7 @@ class SentPr{
|
|
|
|
|
|
public function setPrData($id,$text){
|
|
|
if ($this->dbh_sent) {
|
|
|
- $query = "UPDATE sent_pr set text=? ,modify_time=? WHERE id = ? and editor= ? ";
|
|
|
+ $query = "UPDATE "._TABLE_SENTENCE_PR_." set content=? ,modify_time=? , updated_at = now() WHERE id = ? and editor_uid= ? ";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
$stmt->execute(array($text,mTime(),$id,$_COOKIE["userid"]));
|
|
|
|
|
|
@@ -137,11 +137,13 @@ class Sent_DB
|
|
|
private $dbh_sent;
|
|
|
private $dbh_his;
|
|
|
private $errorMsg="";
|
|
|
+ private $selectCol="uid,parent_uid,block_uid,channel_uid,book_id,paragraph,word_start,word_end,author,editor_uid,content,language,version,status,strlen,modify_time,create_time";
|
|
|
+ private $updateCol="";
|
|
|
public function __construct($redis=false) {
|
|
|
- $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, "", "",array(PDO::ATTR_PERSISTENT=>true));
|
|
|
+ $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
|
|
|
$this->dbh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
|
|
|
|
|
- $this->dbh_his = new PDO(_FILE_DB_USER_SENTENCE_HISTORAY_, "", "",array(PDO::ATTR_PERSISTENT=>true));
|
|
|
+ $this->dbh_his = new PDO(_FILE_DB_USER_SENTENCE_HISTORAY_, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
|
|
|
$this->dbh_his->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
|
|
}
|
|
|
public function getError(){
|
|
|
@@ -150,7 +152,7 @@ class Sent_DB
|
|
|
|
|
|
#获取单个句子数据
|
|
|
public function getSent($book,$para,$begin,$end,$channel){
|
|
|
- $query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ? AND channal = ? ";
|
|
|
+ $query = "SELECT {$this->selectCol} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ? AND channel_uid = ? ";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
if($stmt){
|
|
|
$stmt->execute(array($book,$para,$begin,$end,$channel));
|
|
|
@@ -162,10 +164,10 @@ class Sent_DB
|
|
|
}
|
|
|
}
|
|
|
public function getSentDefaultByLan($book,$para,$begin,$end,$lang){
|
|
|
- $query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ? AND channal = ? ";
|
|
|
+ $query = "SELECT {$this->selectCol} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ? AND language = ? ";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
if($stmt){
|
|
|
- $stmt->execute(array($book,$para,$begin,$end,$channel));
|
|
|
+ $stmt->execute(array($book,$para,$begin,$end,$lang));
|
|
|
$fetchDest = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
return $fetchDest;
|
|
|
}
|
|
|
@@ -183,23 +185,23 @@ class Sent_DB
|
|
|
$this->dbh_sent->beginTransaction();
|
|
|
|
|
|
if(isset($arrData[0]["book"]) && isset($arrData[0]["paragraph"]) && isset($arrData[0]["begin"]) && isset($arrData[0]["end"]) && isset($arrData[0]["channal"])){
|
|
|
- $query = "UPDATE sentence SET text = ? , strlen = ? , editor=?, modify_time= ? , receive_time = ? where book = ? and paragraph=? and [begin]=? and [end]=? and channal=? ";
|
|
|
+ $query = "UPDATE "._TABLE_SENTENCE_." SET content = ? , strlen = ? , editor_uid=?, modify_time= ? ,updated_at=now() where book_id = ? and paragraph=? and word_start=? and word_end=? and channel_uid=? ";
|
|
|
$sth = $this->dbh_sent->prepare($query);
|
|
|
foreach ($arrData as $data) {
|
|
|
if(!isset($data["modify_time"])){
|
|
|
$data["modify_time"] = mTime();
|
|
|
}
|
|
|
- $sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],$data["modify_time"],mTime(),$data["book"],$data["paragraph"],$data["begin"],$data["end"],$data["channal"]));
|
|
|
+ $sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],mTime(),$data["book"],$data["paragraph"],$data["begin"],$data["end"],$data["channal"]));
|
|
|
}
|
|
|
}
|
|
|
else if(isset($arrData[0]["id"])){
|
|
|
- $query = "UPDATE sentence SET text = ? , strlen = ? , editor=?, modify_time= ? ,receive_time = ? where id= ? ";
|
|
|
+ $query = "UPDATE "._TABLE_SENTENCE_." SET content = ? , strlen = ? , editor_uid=?, modify_time= ? ,updated_at = now() where uid= ? ";
|
|
|
$sth = $this->dbh_sent->prepare($query);
|
|
|
foreach ($arrData as $data) {
|
|
|
if(!isset($data["modify_time"])){
|
|
|
$data["modify_time"]=mTime();
|
|
|
}
|
|
|
- $sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],$data["modify_time"],mTime(),$data["id"]));
|
|
|
+ $sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],mTime(),$data["id"]));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -230,26 +232,24 @@ class Sent_DB
|
|
|
if (count($arrData) > 0) {
|
|
|
//add_edit_event(_SENT_NEW_, "{$newList[0]["book"]}-{$newList[0]["paragraph"]}-{$newList[0]["begin"]}-{$newList[0]["end"]}@{$newList[0]["channal"]}");
|
|
|
$this->dbh_sent->beginTransaction();
|
|
|
- $query = "INSERT INTO sentence (id,
|
|
|
- parent,
|
|
|
- book,
|
|
|
+ $query = "INSERT INTO "._TABLE_SENTENCE_." (uid,
|
|
|
+ parent_uid,
|
|
|
+ book_id,
|
|
|
paragraph,
|
|
|
- begin,
|
|
|
- end,
|
|
|
- channal,
|
|
|
- tag,
|
|
|
+ word_start,
|
|
|
+ word_end,
|
|
|
+ channel_uid,
|
|
|
author,
|
|
|
- editor,
|
|
|
- text,
|
|
|
+ editor_uid,
|
|
|
+ content,
|
|
|
language,
|
|
|
- ver,
|
|
|
+ version,
|
|
|
status,
|
|
|
strlen,
|
|
|
modify_time,
|
|
|
- receive_time,
|
|
|
create_time
|
|
|
)
|
|
|
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
|
|
|
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
|
|
|
$sth = $this->dbh_sent->prepare($query);
|
|
|
|
|
|
#查询channel语言
|
|
|
@@ -282,7 +282,6 @@ class Sent_DB
|
|
|
$data["begin"],
|
|
|
$data["end"],
|
|
|
$data["channal"],
|
|
|
- isset($data["tag"]) ? $data["tag"] : "",
|
|
|
$data["author"],
|
|
|
$data["editor"],
|
|
|
$data["text"],
|
|
|
@@ -291,7 +290,6 @@ class Sent_DB
|
|
|
$status,
|
|
|
mb_strlen($data["text"], "UTF-8"),
|
|
|
$data["modify_time"],
|
|
|
- $data["receive_time"],
|
|
|
$data["create_time"]
|
|
|
));
|
|
|
}
|
|
|
@@ -320,24 +318,22 @@ class Sent_DB
|
|
|
return true;
|
|
|
}
|
|
|
$this->dbh_sent->beginTransaction();
|
|
|
- $query = "INSERT INTO sent_pr (id,
|
|
|
- book,
|
|
|
+ $query = "INSERT INTO "._TABLE_SENTENCE_PR_." (
|
|
|
+ book_id,
|
|
|
paragraph,
|
|
|
- begin,
|
|
|
- end,
|
|
|
- channel,
|
|
|
- tag,
|
|
|
+ word_start,
|
|
|
+ word_end,
|
|
|
+ channel_uid,
|
|
|
author,
|
|
|
- editor,
|
|
|
- text,
|
|
|
+ editor_uid,
|
|
|
+ content,
|
|
|
language,
|
|
|
status,
|
|
|
strlen,
|
|
|
modify_time,
|
|
|
- receive_time,
|
|
|
create_time
|
|
|
)
|
|
|
- VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
|
|
|
+ VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
|
|
|
$stmt = $this->dbh_sent->prepare($query);
|
|
|
|
|
|
foreach ($arrData as $data) {
|
|
|
@@ -349,7 +345,6 @@ class Sent_DB
|
|
|
$data["end"],
|
|
|
$data["channal"],
|
|
|
"",
|
|
|
- "[]",
|
|
|
$data["editor"],
|
|
|
$data["text"],
|
|
|
$data["language"],
|
|
|
@@ -357,7 +352,6 @@ class Sent_DB
|
|
|
mb_strlen($data["text"], "UTF-8"),
|
|
|
mTime(),
|
|
|
mTime(),
|
|
|
- mTime(),
|
|
|
));
|
|
|
}
|
|
|
$this->dbh_sent->commit();
|
|
|
@@ -381,7 +375,7 @@ class Sent_DB
|
|
|
}
|
|
|
$this->dbh_his->beginTransaction();
|
|
|
# 更新historay
|
|
|
- $query = "INSERT INTO sent_historay (sent_id, user_id, text, date, landmark) VALUES (? , ? , ? , ? , ? )";
|
|
|
+ $query = "INSERT INTO "._TABLE_SENTENCE_HISTORAY_." (sent_uid, user_uid, content, date, landmark) VALUES (? , ? , ? , ? , ? )";
|
|
|
$stmt = $this->dbh_his->prepare($query);
|
|
|
|
|
|
foreach ($arrData as $data) {
|