public function __construct()
 {
     //加载配置文件
     $confPath = APP_PATH . "Conf/config.ini";
     if (file_exists($confPath)) {
         $this->conf = parse_ini_file($confPath, true);
     }
     $method = strtolower($_SERVER['REQUEST_METHOD']);
     if (!in_array($method, $this->allowMethod)) {
         $method = "get";
     }
     if (!method_exists($this, $method)) {
         RestPHP::error($method . "() method not exists");
     }
     // 所有方法
     if (method_exists($this, "any")) {
         $this->any();
     }
     $this->{$method}();
 }
Beispiel #2
0
 /**
  * 删除数据
  * 
  * @return boolean
  */
 protected function delete()
 {
     if (!$this->_where) {
         RestPHP::error("更新条件不能空");
     }
     $sql = "DELETE FROM {$this->_table}  WHERE " . $this->_where . ";";
     $sth = $this->db->prepare($sql);
     $rs = $sth->execute();
     return $rs;
 }
Beispiel #3
0
 /**
  * 自动载入
  *
  * @param unknown $class            
  */
 public static function autoload($class)
 {
     $classpath = str_replace("\\", "/", APP_PATH . $class . ".class.php");
     if (file_exists($classpath)) {
         require_once $classpath;
     } else {
         $message = $classpath . " not exists ";
         RestPHP::error($message);
     }
 }