con = new PDO('mysql:host=localhost;dbname=oshietyadb;charset=utf8', 'tanaka', 'udRXg3Yx');
$this->con = new PDO('mysql:host=localhost;dbname=eventdb;charset=utf8', 'event', 'L523GpA');
$this->con->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
public function getRegist_list() {
$this->DBAccess();
$regist_data_list = null;
try {
//mysql_query("set names utf8");
$this->sql = "select regist_id,regist_name,regist_lat,regist_lng,category_id,file_name from " . $this->regist_tableName . " where regist_id != 999 and visiflag=1 order by regist_id asc";
$this->res = $this->con->query($this->sql);
while ($row = $this->res->fetch()) {
$regist_data = new Regist_data();
$regist_data->setRegist_id($row['regist_id']);
$regist_data->setRegist_name($row['regist_name']);
$regist_data->setRegist_lat($row['regist_lat']);
$regist_data->setRegist_lng($row['regist_lng']);
$regist_data->setCategory_id($row['category_id']);
$regist_data->setFile_name($row['file_name']);
$regist_data_list[] = $regist_data;
}
} catch (Exception $ex) {
//echo "ID取得エラー";
}
//$this->DBclose();
if ($regist_data_list != null) {
return $regist_data_list;
} else {
return null;
}
}
public function getRefine_list($select_category) {
if ($select_category != null) {
$refine = "and category_id in(";
for ($i = 0; $select_category[$i] != null; $i++) {
//$refine .= $select_category[$i];
$refine .= "?";
if ($select_category[($i + 1)] != null) {
$refine .= ",";
}
}
$refine .= ")";
}
$this->DBAccess();
$regist_data_list = null;
try {
mysql_query("set names utf8");
$this->sql = "select regist_id,regist_name,regist_lat,regist_lng,category_id,file_name from " . $this->regist_tableName . " where regist_id != 999 and visiflag=1 ";
$this->sql .= $refine . " order by regist_id asc";
$this->res = $this->con->prepare($this->sql);
for ($i = 0; $select_category[$i] != null; $i++) {
$this->res->bindValue(($i + 1), $select_category[$i], PDO::PARAM_INT);
}
$this->res->execute();
while ($row = $this->res->fetch()) {
$regist_data = new Regist_data();
$regist_data->setRegist_id($row['regist_id']);
$regist_data->setRegist_name($row['regist_name']);
$regist_data->setRegist_lat($row['regist_lat']);
$regist_data->setRegist_lng($row['regist_lng']);
$regist_data->setCategory_id($row['category_id']);
$regist_data->setFile_name($row['file_name']);
$regist_data_list[] = $regist_data;
}
} catch (Exception $ex) {
//echo "ID取得エラー";
}
if ($regist_data_list != null) {
return $regist_data_list;
} else {
return null;
}
}
public function get_categroy() {
$this->DBAccess();
$category_list = null;
try {
$this->sql = "select * from " . $this->category_tableName . " order by category_id asc";
$this->res = $this->con->query($this->sql);
while ($row = $this->res->fetch()) {
$category_data = new Category_data();
$category_data->setCategory_id($row['category_id']);
$category_data->setCategory_name($row['category_name']);
$category_list[] = $category_data;
}
} catch (Exception $ex) {
//echo "ID取得エラー";
}
if ($category_list != null) {
return $category_list;
} else {
return null;
}
}
public function getModal_data($regist_id) {
$this->DBAccess();
try {
$this->sql = "select regist_name,file_name from " . $this->regist_tableName . " where visiflag=1 and regist_id=:regist_id";
$this->res = $this->con->prepare($this->sql);
$this->res->bindValue(':regist_id', $regist_id, PDO::PARAM_INT);
$this->res->execute();
$data = $this->res->fetch();
$modal_data = htmlspecialchars($data['regist_name']) . "," . $data['file_name'];
} catch (Exception $ex) {
// echo "ID取得エラー";
}
unset($data, $regist_id);
if ($modal_data != null) {
return $modal_data;
} else {
return null;
}
}
public function get_text_data($regist_id) {
$this->DBAccess();
$modal_text = "";
try {
$this->sql = "select text_data from " . $this->text_tableName . " where regist_id=:regist_id order by line_id asc";
$this->res = $this->con->prepare($this->sql);
$this->res->bindValue(':regist_id', $regist_id, PDO::PARAM_INT);
$this->res->execute();
$i = 0;
while ($row = $this->res->fetch()) {
if ($row['text_data'] != null) {
$modal_text .= htmlspecialchars($row['text_data']);
$modal_text = str_replace(" ", " ", $modal_text);
}
if ($i < 7) {
$modal_text .= "
";
}
$i++;
}
} catch (Exception $ex) {
//echo "ID取得エラー";
}
unset($regist_id, $i);
if ($modal_text != null) {
return urldecode(preg_replace('/(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/', '\\1\\2', $modal_text));
} else {
return null;
}
}
public function get_infodata($regist_id) {
$this->DBAccess();
try {
$this->sql = "select regist_name,category_id from " . $this->regist_tableName . " where visiflag=1 and regist_id=:regist_id";
$this->res = $this->con->prepare($this->sql);
$this->res->bindValue(':regist_id', $regist_id, PDO::PARAM_INT);
$this->res->execute();
$data = $this->res->fetch();
$info_data = htmlspecialchars($data['regist_name']) . "," . $data['category_id'];
} catch (Exception $ex) {
//echo "ID取得エラー";
}
unset($data, $regist_id);
if ($info_data != null) {
return $info_data;
} else {
return null;
}
}
public function get_text_infodata($regist_id) {
$this->DBAccess();
$info_text = "";
try {
$this->sql = "select text_data from " . $this->text_tableName . " where regist_id=:regist_id order by line_id asc";
$this->res = $this->con->prepare($this->sql);
$this->res->bindValue(':regist_id', $regist_id, PDO::PARAM_INT);
$this->res->execute();
$i = 0;
while ($row = $this->res->fetch()) {
if ($row['text_data'] != null) {
$info_text .= htmlspecialchars($row['text_data']);
$info_text = str_replace(" ", " ", $info_text);
}
if ($i < 7) {
$info_text .= "\n";
}
$i++;
}
} catch (Exception $ex) {
//echo "ID取得エラー";
}
unset($regist_id, $i);
if ($info_text != null) {
return $info_text;
} else {
return null;
}
}
public function getRegist_tableName() {
return $this->regist_tableName;
}
public function getText_tableName() {
return $this->text_tableName;
}
public function getCategory_tableName() {
return $this->category_tableName;
}
public function setRegist_tableName($regist_tableName) {
$this->regist_tableName = $regist_tableName;
}
public function setText_tableName($text_tableName) {
$this->text_tableName = $text_tableName;
}
public function setCategory_tableName($category_tableName) {
$this->category_tableName = $category_tableName;
}
}