Viewing file: my_ea_model.php (3.27 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
* System in Educational Enterprise Resource Planning System
*
* LICENSE
*
* This source file is subject to the GPL license that is bundled
* with this package in the file alumni_licence.php
*
* @package System in Educational Enterprise Resource Planning System
* @subpackage Alumni System
* @copyright Copyright (C) 2011 by Information System Engineering Research Labolatory, Burapha University
http://iserl.buu.ac.th
iserl.callcenter@gmail.com
* @license http://cvs.buu.ac.th/mis/alumni_licence.php GNU GPL v1
* @author Information System Engineering Research Labolatory, Burapha University
*
*
*/
class My_ea_model extends CI_Model {
protected $ppc_dbname;
protected $rg_dbname;
protected $ea_dbname;
public $last_query;
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->ppc_dbname = $this->config->item('ppc_dbname');
$this->ea_dbname = $this->config->item('ea_dbname');
$this->rg_dbname = $this->config->item('rg_dbname');
}
function row2attribute($rw) {
foreach ($rw as $key => $value) {
if ( is_null($value) )
eval("\$this->$key = NULL;");
else
eval("\$this->$key = '$value';");
}
}
/**
* หน้าที่ของฟังก์ชั่น คือ ต่อสตริงของ sql->where
*
* @access public
* @param array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value)
* @return string con โดยอยู่ในรูปแบบ WHERE $field='$value'
*/
public function checkCondition($condition="") {
$con = "";
if($condition) {
$con .= "WHERE";
foreach($condition as $key => $value) {
if ($value=='NULL')
$con .= " $key IS $value AND";
else if ((substr($value, 0, 1) == '%') || (substr($value, -1) == '%'))
$con .= " $key LIKE '$value' AND";
else
$con .= " $key='$value' AND";
}
}
return $con;
}
/**
* หน้าที่ของฟังก์ชั่น คือ ต่อสตริงของ sql->order by
*
* @access public
* @param array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value)
* @return string con โดยอยู่ในรูปแบบ ORDER $field
*/
public function checkOrderBy($condition="") {
$con = "";
if($condition) {
$con .= "ORDER BY";
foreach ($condition as $key => $value) {
if($value=="") {
$con .= " CONVERT($key USING TIS620) $value,";
} else {
//$con .= " $key,";
$con .= " $key $value,";
}
}
}
return $con;
}
/**
* หน้าที่ของฟังก์ชั่น คือ ต่อสตริงของ sql->group by
*
* @access public
* @param array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value)
* @return string con โดยอยู่ในรูปแบบ GROUP BY $field
*/
public function checkGroupBy($condition="") {
$con = "";
if($condition) {
$con .= "GROUP BY";
foreach ($condition as $key => $value) {
$con .= " $value ,";
}
}
return $con;
}
}
?>
|