quote($word.'%')." OR \"word\" like ".$PDO->quote($word.'%')." group by word limit 0,10";
$Fetch = PDO_FetchAll($query);
if(count($Fetch)<5){
$query = "select word,meaning from term where \"eword\" like ".$PDO->quote('%'.$word.'%')." OR \"word\" like ".$PDO->quote('%'.$word.'%')." group by word limit 0,10";
$Fetch2 = PDO_FetchAll($query);
//去掉重复的
foreach($Fetch2 as $onerow){
$found=false;
foreach($Fetch as $oldArray){
if($onerow["word"]==$oldArray["word"]){
$found=true;
break;
}
}
if($found==false){
array_push($Fetch,$onerow);
}
}
if(count($Fetch)<8){
$query = "select word,meaning from term where \"meaning\" like ".$PDO->quote($word.'%')." OR \"other_meaning\" like ".$PDO->quote($word.'%')." group by word limit 0,10";
$Fetch3 = PDO_FetchAll($query);
$Fetch = array_merge($Fetch,$Fetch3);
if(count($Fetch)<8){
$query = "select word,meaning from term where \"meaning\" like ".$PDO->quote('%'.$word.'%')." OR \"other_meaning\" like ".$PDO->quote('%'.$word.'%')." group by word limit 0,10";
$Fetch4 = PDO_FetchAll($query);
//去掉重复的
foreach($Fetch4 as $onerow){
$found=false;
foreach($Fetch as $oldArray){
if($onerow["word"]==$oldArray["word"]){
$found=true;
break;
}
}
if($found==false){
array_push($Fetch,$onerow);
}
}
}
}
}
echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
break;
}
case "my":
{
$query = "select guid,word,meaning,other_meaning from term where owner= ".$PDO->quote($username);
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
if($iFetch>0){
echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
}
break;
}
case "allpali":
{
$query = "select word from term where 1 group by word";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
if($iFetch>0){
echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
}
break;
}
case "allmean":
{
$query = "select meaning from term where \"word\" = ".$PDO->quote($word)." group by meaning";
$Fetch = PDO_FetchAll($query);
foreach($Fetch as $one){
echo "".$one["meaning"]." ";
}
//echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
break;
}
case "load_id":
{
if(isset($_GET["id"])){
$id=$_GET["id"];
$query = "select * from term where \"guid\" = ".$PDO->quote($id);
$Fetch = PDO_FetchAll($query);
echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
}
else{
echo json_encode(array(), JSON_UNESCAPED_UNICODE);
}
break;
}
case "search":
{
if(!isset($word)){
return;
}
if(trim($word)==""){
return;
}
echo"
{$word}
";
//查本人数据
echo "";//My Term
$query = "select * from term where \"word\" = ".$PDO->quote($word)." AND \"owner\"= ".$PDO->quote($username)." limit 0,30";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
$count_return+=$iFetch;
if($iFetch>0){
for($i=0;$i<$iFetch;$i++){
$mean=$Fetch[$i]["meaning"];
$guid=$Fetch[$i]["guid"];
$dict_list[$guid]=$Fetch[$i]["owner"];
echo "