/
selectwords-class.php
55 lines (54 loc) · 1.51 KB
/
selectwords-class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* 単語翻訳
*
*
*/
class SelectWords extends Executer
{
public function execute($varNameArray, $sqlpre, $value, $placeHolderArray)
{
//todo データバインドの方法を変える以下がんばれ
$countValueArray = count($value);
$countVarNameArray = count($varNameArray);
for ($i=0; $i < $countValueArray; $i++) {
//for ($i=0; $i < 10; $i++) {
for($j=0; $j < $countVarNameArray; $j++) {
$$varNameArray[$j] =
WordRepair::wordFirstUpperCaseRepair($value[$i]);
$sqlpre->bindValue
(
$placeHolderArray[$j],
$$varNameArray[$j]
);
}
$sqlpre->execute();
$result[$i] = $this->examineResult($sqlpre->fetchAll());
$result[$i][0]["enword"] = $value[$i];
}
return $result;
}
public function examineResult($result)
{
if(empty($result)){
return array(array("transword"=>"NOresult",0=>"NOresult"));
}
return $result;
}
}
class WordRepair {
static function wordFirstUpperCaseRepair ($word)
{
$pattern = '/^I|[A-Z]{2,}/';
$matchreturn = preg_match($pattern, $word, $match);
if (
$matchreturn === 0 ||
$matchreturn === false
){
$repairWord = strtolower($word);
}else{
$repairWord = $word;
}
return $repairWord;
}
}