今天偶尔兴趣,调试一下以前在Win下写的数据库封装类,结果出现Fatal error: Class 'option' not found的奇怪错误,很郁闷,前面是打印了一大片optin类的源代码,然后就是Xdebug的错误报告,这到底嘛子问题,以为是类声明的问题,然后用require_once加载了所有文件,还是不行
我的数据库类执行顺序是:mysql extends db; db extends option;调用方法是$db = db::getinstance('mysql');  $db -> Config($config); $db->find();
为什么在Win下可以,在Linux下不行,测试过,不是文件权限的问题,也不是文件命名的问题;用过直接加载,也用过__autoload;为什么会把option整个文件的代码都打印在网页上面?
实在没办法了
求解答!

解决方案 »

  1.   

    抱歉!马上到!.$this -> group .$this -> order .$this -> limit .$this -> lock ; return $this -> select($this -> db_SQL); } // /** // * 获取一条记录 // */ // public function FindOne(){ // // } // /** // * 更新锁 // */ // public function UpLock(){ // // } } 
    ( ! ) Fatal error: Class 'option' not found in /opt/www/DB/db.php on line 10
    Call Stack
    # Time Memory Function Location
    1 0.1073 239368 {main}( ) ../index.php:0
    2 0.1075 242008 __autoload( ??? ) ../index.php:10
    3 0.1082 280080 require_once( '/opt/www/DB/db.php' ) ../index.php:6
    上面的代码没全部复制,下面是xdebug的错误信息
      

  2.   

    但是已经require加载option,结果就是打印了一大片的option源代码
    table); if (is_array($tables)){ foreach($tables as $key => $table){ $this -> table .= "$table AS $key"; } }else{$this -> table = $tables;} return $this; } /** * 获取字段名 */ public function SetField($field){ $this -> field = $field; return $this; } /** * Where 子句设置 */ public function Where($data = ''){ $this -> where = !empty($data) ? ' WHERE '.trim($data) : ''; return $this; } /** * Order 排序设置 */ public function Order($data = ''){ $this -> order = !empty($data) ? ' ORDER BY '.trim($data) : ''; return $this; } /** * Limit 分页设置 */ public function Limit($data = ''){ $this -> limit = !empty($data) ? ' LIMIT '.trim($data) : ''; return $this; } /** * 数据锁设置 */ public function Lock($data = false){ if ($data) { $this -> lock = ' FOR UPDATE '; if ($this -> db_type === 'Oracle'){ $this -> lock = ' FOR UPDATE NOWAIT '; } } return $this; } /** * Group分组设置 */ public function Group($data = ''){ $this -> group = !empty($data) ? ' GROUP BY '.trim($data) : ''; return $this; } /** * JoinON表连接设置 * $data is string or array; * $data = 'table T ON T.ID = X.TID' or array('table T' => 'T.ID = X.ID'); * 支持多表查询,多表连接使用数组赋值 * $option = 'LEFT' OR 'RIGHT' OR 'INNER'; */ function JoinON($data = '',$option = 'INNER',$table = ''){ if (is_string($data)){ $join = " $option JOIN $data"; }elseif (is_array($data)){ foreach($data as $field => $on){ $join .= ' '.$option.' JOIN '. $field.' ON '.$on;  } } $this -> joinON = $table.$join; return $this; } /** * 添加数据 * $data = array('field' = 'value'); */ public function Insert($data = '',$table = ''){ if (!is_null($this -> db_SQL)) unset($this -> db_SQL); if (empty($table)){ $table = $this -> table;  } if (empty($data)){ $data = $this -> data; }  if (is_array($data)){ foreach($data as $key => $value){ $fields = is_null($fields) ? $key : "{$fields},{$key}"; $values = is_null($values) ? "'{$value}'" : "'{$values}','{$value}'"; }  }else{ exit('参数错误');  } $this -> db_SQL = "INSERT INTO {$table} ({$fields}) VALUES ({$values})"; return $this -> query($this -> db_SQL); } /** * 修改/更新数据 * $data = array('fileds' => 'new value'); or array(array('fileds1' => 'new value1'),array('field2' => 'new value2')); * table = 'table'; or array('table1','table2'); */ public function Update($data = '',$table = '',$option = ''){ if (!is_null($this -> db_SQL)) unset($this -> db_SQL); if (empty($table)) $table = $this -> table;  if (empty($data)) $data = $this -> data; if (!is_array($data)) exit('参数错误!'); if (is_array($table)){ foreach($table as $v){ $tables = is_null($tables) ? $v : "{$tables},$v"; } foreach($data as $k => $v){ foreach($v as $key => $value){ $values = is_null($values) ? "{$table[$k]}.{$key} = '{$value}'" : "{$values},{$table[$k]}.{$key} = '{$value}'"; } } }else{ $tables = $table; foreach($data as $key => $value){ $values = is_null($values) ? "{$key} = '{$value}'" : "{$values},{$key} = '{$value}'"; } } if (isset($option['where'])) $this -> Where($option['where']); if (isset($option['order'])) $this -> Order($option['order']); if (isset($option['limit'])) $this -> Limit($option['limit']); $this -> db_SQL = "UPDATE {$tables} SET {$values}" .$this -> where .$this -> order .$this -> limit; return $this -> query($this -> db_SQL); } /** * 删除记录 * $data = truncate; 删除所有数据 */ public function Drop($option = '',$table = ''){ if (!is_null($this -> db_SQL)) unset($this -> db_SQL); if (empty($table)) $table = $this -> table;  if (isset($option['where'])) { $this -> Where($option['where']); }elseif($option = 'truncate' or empty($this -> where)){ $this -> db_SQL = 'TRUNCATE TABLE'.$table; }else{ if (isset($option['order'])) $this -> Order($option['order']); if (isset($option['limit'])) $this -> Limit($option['limit']); $this -> db_SQL = "DELETE FROM {$table}" .$this -> where .$this -> order .$this -> limit;  } return $this -> query($this -> db_SQL); } /** * 查询记录 */ public function Find($tables = '',$option = ''){ $tables =!empty($tables) ? $tables : $this -> table;  $fields =!empty($this -> field) ? $this -> field : ' * ';  if (isset($option['join'])) $this -> JoinON($option['join']); if (isset($option['where'])) $this -> Where($option['where']); if (isset($option['group'])) $this -> Group($option['group']); if (isset($option['order'])) $this -> Order($option['order']); if (isset($option['limit'])) $this -> Limit($option['limit']); $this -> db_SQL = "SELECT {$fields} FROM $tables" .$this -> joinON .$this -> where .$this -> group .$this -> order .$this -> limit .$this -> lock ; return $this -> select($this -> db_SQL); } // /** // * 获取一条记录 // */ // public function FindOne(){ // // } // /** // * 更新锁 // */ // public function UpLock(){ // // } } 
    ( ! ) Fatal error: Class 'option' not found in /opt/www/DB/db.php on line 10
    Call Stack
    # Time Memory Function Location
    1 0.1073 239368 {main}( ) ../index.php:0
    2 0.1075 242008 __autoload( ??? ) ../index.php:10
    3 0.1082 280080 require_once( '/opt/www/DB/db.php' ) ../index.php:6
      

  3.   

    php未解析?
    会不会是<?php写成<?样了?
      

  4.   

    /opt/www/DB/db.php ???
    使用绝对路径的?
      

  5.   

    /opt/www/DB/db.php ???
    使用绝对路径的?
      

  6.   

    __autoload自动加载的,前面有做set_include_path配置