dbnt.co.kr2019/common/lib/class.contact.php

207 lines
4.2 KiB
PHP

<?
class Contact {
var $DB;
var $_LIST_NUM = 20;
var $_user_id;
var $_PDS = _PDS;
var $_PDS_SUB = "/contact/";
# 생성자
function Contact($db) {
$this->DB = $db;
$this->_PDS .= $this->_PDS_SUB;
}
/*****
* 등록
*****/
function set_insert($argu){
global $_adminpage;
// foreach($_FILES as $fname => $value){
// if($value[size]>0){
// $tmp_file="tmp_".$fname;
// $del_file="del_".$fname;
// $path = $this->_PDS;
// $_upload[$fname] = zm_upload($fname, $path, $argu[$del_file], $argu[$tmp_file]);
// }
// }
$data = array(
"name" => $argu["name"],
"email" => $argu['email'],
"phone" => $argu['phone'],
"type" => $argu['type'],
"space" => $argu['space'],
"addr1" => $argu["addr1"],
"addr2" => $argu["addr2"],
"beginning" => $argu["beginning"],
"budget" => $argu["budget"],
"content" => strip_tags($argu["content"]),
"status" => "N",
"regdate" => _NowTime,
"upfile" => $argu['upfile'],
"upfile_ori" => $argu['upfile_ori'],
);
$sth = $this->DB->autoPrepare(TABLE_CONTACT, array_keys($data), DB_AUTOQUERY_INSERT);
$res = $this->DB->execute($sth, array_values($data));
if (DB::isError($res)) {
go_url("", $res->getMessage());
exit;
}
$id=mysql_insert_id();
$data=array_merge($data,array("id"=>$id));
return $data;
}
/*****
* 수정
*****/
function set_modify($argu){
// foreach($_FILES as $fname => $value){
// if($value[size]>0){
// $tmp_file="tmp_".$fname;
// $del_file="del_".$fname;
// $path = $this->_PDS;
// $_upload[$fname] = zm_upload($fname, $path, $argu[$del_file], $argu[$tmp_file]);
// }
// }
$data = array(
"name" => $argu["name"],
"email" => $argu['email'],
"phone" => $argu['phone'],
"type" => $argu['type'],
"space" => $argu['space'],
"addr1" => $argu["addr1"],
"addr2" => $argu["addr2"],
"beginning" => $argu["beginning"],
"budget" => $argu["budget"],
"content" => strip_tags($argu["content"]),
"status" => $argu["status"],
);
$res = $result = $this->DB->autoExecute(TABLE_CONTACT, $data,
DB_AUTOQUERY_UPDATE, " id = '{$argu['id']}' ");
if (DB::isError($res)) {
go_url("", $res->getMessage());
exit;
}
return true;
}
/*****
* 삭제.
*****/
function set_delete($argu){
$query = "
delete from ".TABLE_CONTACT."
where id = '{$argu['id']}'
";
$res = $this->DB->query($query);
if (DB::isError($res)) {
go_url("", $res->getMessage());
exit;
}
return true;
}
#리스트 삭제 처리
function set_delete_list($argu){
if(count($argu["chk"]) > 0){
for($i = 0; $i < count($argu["chk"]); $i++){
$argu["id"] = $argu["chk"][$i];
$_list = $this -> set_delete($argu);
}
return true;
}
else{
go_url("","삭제할데이터가 없습니다.");
exit;
}
}
/*****
* 목록을 가져온다.
*****/
function get_list($argu,&$total,$limit = true){
$addwhere = " where (1=1)";
/// 검색쿼리
if($argu['s_string']){ $addwhere .= " and (name like '%{$argu['s_string']}%' or phone like '%{$argu['s_string']}%' or email like '%{$argu['s_string']}%') "; }
$query = "
select
count(*)
from
".TABLE_CONTACT."
".$addwhere;
$res = $total = $this->DB->getOne($query);
if (DB::isError($res)) {
go_url("", $res->getMessage());
exit;
}
$query = "
select
*
from
".TABLE_CONTACT."
".$addwhere."
order by
regdate desc
";
if($limit)
$query .= "
limit ".($argu['p']-1)*$this->_LIST_NUM.",".$this->_LIST_NUM;
$res = $list =& $this->DB->getAll($query, array(), DB_FETCHMODE_ASSOC);
if (DB::isError($res)) {
go_url("", $res->getMessage());
exit;
}
return $list;
}
/*****
* 정보를 가져온다.
*****/
function get_view($id){
$query = "
select
*
from
".TABLE_CONTACT."
where
id = '{$id}'
";
$res = $row = $this->DB->getRow($query,DB_FETCHMODE_ASSOC);
if (DB::isError($res)) {
go_url("", $res->getMessage());
exit;
}
return $row;
}
}
?>