Viewing file: mo_rg_news.php (2.44 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("da_rg_News.php");
class Mo_rg_news extends Da_rg_News {
public function qryNw($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *, CONCAT(YEAR(nwCreateDate),'-',MONTH(nwCreateDate),'-',DAY(nwCreateDate)) AS dateCreate
FROM $this->rg_dbname.rg_News
$c1
$c3
$c2";
$query = $this->db->query($sql);
return $query;
}
public function qryNwJoinUmsystem($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *, CONCAT(YEAR(nwCreateDate),'-',MONTH(nwCreateDate),'-',DAY(nwCreateDate)) AS dateCreate
FROM $this->rg_dbname.rg_News
LEFT JOIN $this->ums_dbname.umsystem ON nwSystem=StID
$c1
$c3
$c2";
$query = $this->db->query($sql);
return $query;
}
public function qryNwNotId($nwTitle, $nwSystem, $nwFrDate, $nwToDate, $nwId) {
$sql = "SELECT *
FROM $this->rg_dbname.rg_News
WHERE nwTitle=?
AND nwSystem=?
AND nwFrDate=?
AND nwToDate=?
AND nwId<>?";
$query = $this->db->query($sql,array($nwTitle, $nwSystem, $nwFrDate, $nwToDate, $nwId));
return $query;
}
/**
* หน้าที่ของฟังก์ชั่น คือ หารหัสคำถามที่มากที่สุด
*
* @access public
* @return faqId: รหัสคำถาม
* @todo use
*/
public function qryMaxNwId() {
$sql = "SELECT MAX(nwId) AS nwId
FROM $this->rg_dbname.rg_News";
$query = $this->db->query($sql);
if($query->num_rows()) {
return $query->row()->nwId+1;
} else {
return 1;
}
}
function qryNwBetweenDateOrderDateDesc($date) {
$sql = "SELECT *, CONCAT(YEAR(nwCreateDate),'-',MONTH(nwCreateDate),'-',DAY(nwCreateDate)) AS dateCreate
FROM $this->rg_dbname.rg_News
LEFT JOIN $this->ums_dbname.umsystem ON nwSystem=StID
WHERE ? BETWEEN nwFrDate AND nwToDate
OR nwFrDate='0000-00-00'
OR nwToDate='0000-00-00'
ORDER BY nwFrDate DESC";
$query = $this->db->query($sql, array($date));
return $query;
}
}
?>
|