<?php
class SwedishDatabaseHandler extends DictionaryDatabaseHandler {
function init(){
parent::init();
$this->username = CONFIG_DB_USER_SWEDISH;
$this->password = CONFIG_DB_PWD_SWEDISH;
$this->database = CONFIG_DB_NAME_SWEDISH;
}
function selectUnconvertedWords($number){
$sql = "SELECT word FROM $this->database.`bayadic_dictionary_de_fa` WHERE status = 'open' limit $number";
$this->connection->query ( "SET NAMES utf8" );
$result = $this->connection->query ( $sql ) or die ( $this->connection->error );
while ($word= mysqli_fetch_assoc($result)){
$words[]=$word;
}
return $words;
}
public function getTrnslations($word, $ln) {
if($ln=="FA"){
$sql= "SELECT id,word, translation FROM `".$this->database."`.`dic_fasv` where word='"
. $word . "' limit 60";
}
else {
$sql= "SELECT id,word, translation FROM `".$this->database."`.`dic_svfa` where word='"
. $word . "' limit 60";
}
$this->connection->query ( "SET NAMES utf8" );
$result = $this->connection->query ( $sql ) or die ( $this->connection->error );
while ($wordArrayResult[] = mysqli_fetch_assoc($result));
if(count ($wordArrayResult) > 0 && !empty($wordArrayResult[0]) ){
$this->wordArrayResult = $wordArrayResult;
$this->translated = true;
}
else {
$this->isSearched($word);
$this->translated = false;
}
return $this->wordArrayResult;
}
function updateTranslation($word,$translation){
$sql = "UPDATE `$this->database`.`bayadic_dictionary_de_fa` SET `wordDESV` = '$translation', `status` = 'glosbed' where word = '$word' ";
$this->connection->query ( "SET NAMES utf8" );
$result = $this->connection->query ( $sql ) or die ( $this->connection->error );
}
public function makeTranslationTextMessage() {
$translated ="";
if(!is_array($this->wordArrayResult)) {
if(!$this->translated /* && !$this->hasSoundex */)
{
$translated ="ingen aning 😭";
}
return $translated;
}
foreach ( $this->wordArrayResult as $word ) {
$additionalInfo = "";
if($word['word']){
$translated.=trim($word['word'])." : ".$word['translation']." ".$additionalInfo.PHP_EOL.PHP_EOL;
}
}
return $translated. " 😊".PHP_EOL." @TranslateSwedish_bot";
}
}
?>