用户
 找回密码
 入住 CI 中国社区
搜索
查看: 14623|回复: 10
收起左侧

[已解决] codeigniter2.0 自动加载数据库类错误,找不到错误原因

[复制链接]
发表于 2012-4-8 11:29:56 | 显示全部楼层 |阅读模式
本帖最后由 core 于 2012-4-9 11:05 编辑

系统:win7 64位
codeigniter版本: 2.0
环境:apache 64位
mysql版本:MySQL Server 5.5  64位

数据库是从autoload自动加载,或者是从控制器或者模型中使用$this->load->database();加载后, 出现错误,但是找不到是什么错误,页面上什么也不显示。 看apache的error日志没有错误。
codeigniter没有错误提示和错误日志文件。

这种情况下该怎么处理。
麻烦大家了。
发表于 2012-4-8 16:14:48 | 显示全部楼层
没有提示错误从哪里可看出是数据库类加载错误呢?
数据库配置有错误吗?
 楼主| 发表于 2012-4-8 16:50:17 | 显示全部楼层
数据库配置没有错误,我直接用php 写mysql_connect代码是可以的。
在DB.php代码里面
        require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php');
        // Instantiate the DB adapter
        $driver = 'CI_DB_'.$params['dbdriver'].'_driver';

        $DB = new $driver($params);

        if ($DB->autoinit == TRUE)
        {
                $DB->initialize();    //走到这里就不往下走了。 跟进去后发现也没有错误。
        }
//下面的代码没有执行,也没有返回。
        if (isset($params['stricton']) && $params['stricton'] == TRUE)
        {
                $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
        }

        return $DB;
}
 楼主| 发表于 2012-4-8 17:52:23 | 显示全部楼层
连接数据库过程中,走到mysql_driver.php文件中,设置字符编码函数中

function db_set_charset($charset, $collation)
{
  if ( ! isset($this->use_set_names))
  {
   // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
   $this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
  }
  if ($this->use_set_names === TRUE)
  { //走这个分支里面,下面没有返回
   return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
  }
  else
  {
   return @mysql_set_charset($charset, $this->conn_id);
  }
}
 楼主| 发表于 2012-4-8 18:22:02 | 显示全部楼层
经过测试, CodeIgniter V 1.7.3版本没有这个问题。
发表于 2012-4-8 18:57:09 | 显示全部楼层
和你 php 的 mysql 扩展有关,贴一下 phpinfo() 结果。
 楼主| 发表于 2012-4-8 22:53:29 | 显示全部楼层
PHP Version 5.2.5 (x64)
System Windows NT CORE 6.1 build 7601
Build Date Nov 12 2007 12:08:19
Configure Command cscript /nologo configure.js  "--enable-snapshot-build" "--enable-mysqlnd"
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File D:\Program Files\php\php.ini
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.zlib   
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


PHP Credits
ConfigurationPHP Core
DirectiveLocal ValueMaster Value
allow_call_time_pass_referenceOffOff
allow_url_fopenOnOn
allow_url_includeOffOff
always_populate_raw_post_dataOffOff
arg_separator.input&&
arg_separator.output&&
asp_tagsOffOff
auto_append_fileno valueno value
auto_globals_jitOnOn
auto_prepend_fileno valueno value
browscapno valueno value
default_charsetno valueno value
default_mimetypetext/htmltext/html
define_syslog_variablesOffOff
disable_classesno valueno value
disable_functionsno valueno value
display_errorsOnOn
display_startup_errorsOffOff
doc_rootno valueno value
docref_extno valueno value
docref_rootno valueno value
enable_dlOnOn
error_append_stringno valueno value
error_logno valueno value
error_prepend_stringno valueno value
error_reporting61436143
expose_phpOnOn
extension_dirD:/Program Files/php/extD:/Program Files/php/ext
file_uploadsOnOn
highlight.bg#FFFFFF#FFFFFF
highlight.comment#FF8000#FF8000
highlight.default#0000BB#0000BB
highlight.html#000000#000000
highlight.keyword#007700#007700
highlight.string#DD0000#DD0000
html_errorsOnOn
ignore_repeated_errorsOffOff
ignore_repeated_sourceOffOff
ignore_user_abortOffOff
implicit_flushOffOff
include_path.;C:\php5\pear.;C:\php5\pear
log_errorsOnOn
log_errors_max_len10241024
magic_quotes_gpcOffOff
magic_quotes_runtimeOffOff
magic_quotes_sybaseOffOff
mail.force_extra_parametersno valueno value
max_execution_time3030
max_input_nesting_level6464
max_input_time6060
memory_limit128M128M
open_basedirno valueno value
output_buffering40964096
output_handlerno valueno value
post_max_size8M8M
precision1414
realpath_cache_size16K16K
realpath_cache_ttl120120
register_argc_argvOffOff
register_globalsOffOff
register_long_arraysOffOff
report_memleaksOnOn
report_zend_debugOnOn
safe_modeOffOff
safe_mode_exec_dirno valueno value
safe_mode_gidOffOff
safe_mode_include_dirno valueno value
sendmail_fromlehoons@gmail.comlehoons@gmail.com
sendmail_pathno valueno value
serialize_precision100100
short_open_tagOffOff
SMTPlocalhostlocalhost
smtp_port2525
sql.safe_modeOffOff
track_errorsOffOff
unserialize_callback_funcno valueno value
upload_max_filesize2M2M
upload_tmp_dirno valueno value
user_dirno valueno value
variables_orderGPCSGPCS
xmlrpc_error_number00
xmlrpc_errorsOffOff
y2k_complianceOnOn
zend.ze1_compatibility_modeOffOff

apache2handler
Apache Version Apache/2.2.19 (Win64) PHP/5.2.5 (x64)
Apache API Version 20051115
Server Administrator admin@example.com
Hostnameort localhost:80
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 300 - Keep-Alive: 5
Virtual Server No
Server Root D:/Program Files/Apache
Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_php5

DirectiveLocal ValueMaster Value
engine11
last_modified00
xbithack00

Apache Environment
VariableValue
HTTP_ACCEPT text/html, application/xhtml+xml, */*
HTTP_ACCEPT_LANGUAGE zh-CN
HTTP_USER_AGENT Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; BOIE9;ZHCNMSE)
HTTP_UA_CPU AMD64
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_HOST localhost
HTTP_CONNECTION Keep-Alive
PATH C:\Program Files (x86)\Common Files\NetSarang;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Program Files\MySQL\MySQL Server 5.5\bin;
SystemRoot C:\Windows
COMSPEC C:\Windows\system32\cmd.exe
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR C:\Windows
SERVER_SIGNATURE no value
SERVER_SOFTWARE Apache/2.2.19 (Win64) PHP/5.2.5 (x64)
SERVER_NAME localhost
SERVER_ADDR 127.0.0.1
SERVER_PORT 80
REMOTE_ADDR 127.0.0.1
DOCUMENT_ROOT D:/Program Files/Apache/htdocs
SERVER_ADMIN admin@example.com
SCRIPT_FILENAME D:/Program Files/Apache/htdocs/index.php
REMOTE_PORT 5007
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING no value
REQUEST_URI /
SCRIPT_NAME /index.php

HTTP Headers Information
HTTP Request Headers
HTTP Request GET / HTTP/1.1
Accept text/html, application/xhtml+xml, */*
Accept-Language zh-CN
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; BOIE9;ZHCNMSE)
UA-CPU AMD64
Accept-Encoding gzip, deflate
Host localhost
Connection Keep-Alive
HTTP Response Headers
X-Powered-By PHP/5.2.5 (x64)
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html

bcmath
BCMath support enabled

calendar
Calendar support enabled

com_dotnet
COM supportenabled
DCOM supportdisabled
.Net supportenabled

DirectiveLocal ValueMaster Value
com.allow_dcom00
com.autoregister_casesensitive11
com.autoregister_typelib00
com.autoregister_verbose00
com.code_pageno valueno value
com.typelib_fileno valueno value

ctype
ctype functions enabled

date
date/time support enabled
"Olson" Timezone Database Version 2007.9
Timezone Database internal
Default timezone UTC

DirectiveLocal ValueMaster Value
date.default_latitude31.766731.7667
date.default_longitude35.233335.2333
date.sunrise_zenith90.58333390.583333
date.sunset_zenith90.58333390.583333
date.timezoneno valueno value

dom
DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.6.27
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled

filter
Input Validation and Filtering enabled
Revision $Revision: 1.52.2.39 $

DirectiveLocal ValueMaster Value
filter.defaultunsafe_rawunsafe_raw
filter.default_flagsno valueno value

ftp
FTP support enabled

gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

hash
hash support enabled
Hashing Engines md2 md4 md5 sha1 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru gost adler32 crc32 crc32b haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5  

iconv
iconv support enabled
iconv implementation "libiconv"
iconv library version 1.9

DirectiveLocal ValueMaster Value
iconv.input_encodingISO-8859-1ISO-8859-1
iconv.internal_encodingISO-8859-1ISO-8859-1
iconv.output_encodingISO-8859-1ISO-8859-1

json
json support enabled
json version 1.2.1

libxml
libXML support active
libXML Version 2.6.27
libXML streams enabled

mbstring
Multibyte Support enabled
Multibyte string engine libmbfl
Multibyte (japanese) regex support enabled
Multibyte regex (oniguruma) version 4.4.4
Multibyte regex (oniguruma) backtrack check On

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

DirectiveLocal ValueMaster Value
mbstring.detect_orderno valueno value
mbstring.encoding_translationOffOff
mbstring.func_overload00
mbstring.http_inputpasspass
mbstring.http_outputpasspass
mbstring.internal_encodingno valueno value
mbstring.languageneutralneutral
mbstring.strict_detectionOffOff
mbstring.substitute_characterno valueno value

mysql
MySQL Supportenabled
Active Persistent Links 1
Active Links 1
Client API version 5.0.19

DirectiveLocal ValueMaster Value
mysql.allow_persistentOnOn
mysql.connect_timeout6060
mysql.default_hostlocalhostlocalhost
mysql.default_passwordrootroot
mysql.default_port33063306
mysql.default_socketno valueno value
mysql.default_userrootroot
mysql.max_linksUnlimitedUnlimited
mysql.max_persistentUnlimitedUnlimited
mysql.trace_modeOffOff

mysqli
MysqlI Supportenabled
Client API library version 5.0.19
Client API header version 4.1.7
MYSQLI_SOCKET /tmp/mysql.sock

DirectiveLocal ValueMaster Value
mysqli.default_hostno valueno value
mysqli.default_port33063306
mysqli.default_pwno valueno value
mysqli.default_socketno valueno value
mysqli.default_userno valueno value
mysqli.max_linksUnlimitedUnlimited
mysqli.reconnectOffOff

odbc
ODBC Supportenabled
Active Persistent Links 0
Active Links 0
ODBC library Win32

DirectiveLocal ValueMaster Value
odbc.allow_persistentOnOn
odbc.check_persistentOnOn
odbc.default_dbno valueno value
odbc.default_pwno valueno value
odbc.default_userno valueno value
odbc.defaultbinmodereturn as isreturn as is
odbc.defaultlrlreturn up to 4096 bytesreturn up to 4096 bytes
odbc.max_linksUnlimitedUnlimited
odbc.max_persistentUnlimitedUnlimited

pcre
PCRE (Perl Compatible Regular Expressions) Support enabled
PCRE Library Version 7.3 2007-08-28

DirectiveLocal ValueMaster Value
pcre.backtrack_limit100000100000
pcre.recursion_limit100000100000

Reflection
Reflectionenabled
Version $Id: php_reflection.c,v 1.164.2.33.2.47 2007/10/28 13:47:14 iliaa Exp $

session
Session Support enabled
Registered save handlers files user  
Registered serializer handlers php php_binary wddx  

DirectiveLocal ValueMaster Value
session.auto_startOffOff
session.bug_compat_42OffOff
session.bug_compat_warnOnOn
session.cache_expire180180
session.cache_limiternocachenocache
session.cookie_domainno valueno value
session.cookie_httponlyOffOff
session.cookie_lifetime00
session.cookie_path//
session.cookie_secureOffOff
session.entropy_fileno valueno value
session.entropy_length00
session.gc_divisor10001000
session.gc_maxlifetime14401440
session.gc_probability11
session.hash_bits_per_character55
session.hash_function00
session.namePHPSESSIDPHPSESSID
session.referer_checkno valueno value
session.save_handlerfilesfiles
session.save_pathno valueno value
session.serialize_handlerphpphp
session.use_cookiesOnOn
session.use_only_cookiesOffOff
session.use_trans_sid00

SimpleXML
Simplexml supportenabled
Revision $Revision: 1.151.2.22.2.35 $
Schema support enabled

SPL
SPL supportenabled
Interfaces Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilterIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RegexIterator, RuntimeException, SimpleXMLIterator, SplFileInfo, SplFileObject, SplObjectStorage, SplTempFileObject, UnderflowException, UnexpectedValueException

standard
Regex Library Bundled library enabled
Dynamic Library Support enabled
Internal Sendmail Support for Windows enabled

DirectiveLocal ValueMaster Value
assert.active11
assert.bail00
assert.callbackno valueno value
assert.quiet_eval00
assert.warning11
auto_detect_line_endings00
default_socket_timeout6060
safe_mode_allowed_env_varsPHP_PHP_
safe_mode_protected_env_varsLD_LIBRARY_PATHLD_LIBRARY_PATH
url_rewriter.tagsa=href,area=href,frame=src,input=src,form=fakeentrya=href,area=href,frame=src,input=src,form=fakeentry
user_agentno valueno value

tokenizer
Tokenizer Support enabled

wddx
WDDX Supportenabled
WDDX Session Serializer enabled

xml
XML Support active
XML Namespace Support active
libxml2 Version 2.6.27

xmlreader
XMLReader enabled

xmlwriter
XMLWriter enabled

zlib
ZLib Support enabled
Stream Wrapper support compress.zlib://
Stream Filter support zlib.inflate, zlib.deflate
Compiled Version 1.2.3
Linked Version 1.2.3

DirectiveLocal ValueMaster Value
zlib.output_compressionOffOff
zlib.output_compression_level-1-1
zlib.output_handlerno valueno value

Additional Modules
Module Name

Environment
VariableValue
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Windows\system32\config\systemprofile\AppData\Roaming
CommonProgramFiles C:\Program Files\Common Files
CommonProgramFiles(x86) C:\Program Files (x86)\Common Files
CommonProgramW6432 C:\Program Files\Common Files
COMPUTERNAME CORE
ComSpec C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK NO
LOCALAPPDATA C:\Windows\system32\config\systemprofile\AppData\Local
NUMBER_OF_PROCESSORS 2
OS Windows_NT
Path C:\Program Files (x86)\Common Files\NetSarang;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Program Files\MySQL\MySQL Server 5.5\bin;
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE AMD64
PROCESSOR_IDENTIFIER Intel64 Family 6 Model 23 Stepping 10, GenuineIntel
PROCESSOR_LEVEL 6
PROCESSOR_REVISION 170a
ProgramData C:\ProgramData
ProgramFiles C:\Program Files
ProgramFiles(x86) C:\Program Files (x86)
ProgramW6432 C:\Program Files
PSModulePath C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC C:\Users\Public
SystemDrive C:
SystemRoot C:\Windows
TEMP C:\Windows\TEMP
TMP C:\Windows\TEMP
TSMPATH C:\Program Files\ThinkPad\UltraNav Utility
TVT C:\Program Files (x86)\Lenovo
USERDOMAIN WORKGROUP
USERNAME CORE$
USERPROFILE C:\Windows\system32\config\systemprofile
VS100COMNTOOLS D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
windir C:\Windows
windows_tracing_flags 3
windows_tracing_logfile C:\BVTBin\Tests\installpackage\csilogfile.log
AP_PARENT_PID 1544

PHP Variables
VariableValue
_SERVER["HTTP_ACCEPT"]text/html, application/xhtml+xml, */*
_SERVER["HTTP_ACCEPT_LANGUAGE"]zh-CN
_SERVER["HTTP_USER_AGENT"]Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; BOIE9;ZHCNMSE)
_SERVER["HTTP_UA_CPU"]AMD64
_SERVER["HTTP_ACCEPT_ENCODING"]gzip, deflate
_SERVER["HTTP_HOST"]localhost
_SERVER["HTTP_CONNECTION"]Keep-Alive
_SERVER["ATH"]C:\Program Files (x86)\Common Files\NetSarang;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Program Files\MySQL\MySQL Server 5.5\bin;
_SERVER["SystemRoot"]C:\Windows
_SERVER["COMSPEC"]C:\Windows\system32\cmd.exe
_SERVER["ATHEXT"].COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
_SERVER["WINDIR"]C:\Windows
_SERVER["SERVER_SIGNATURE"]no value
_SERVER["SERVER_SOFTWARE"]Apache/2.2.19 (Win64) PHP/5.2.5 (x64)
_SERVER["SERVER_NAME"]localhost
_SERVER["SERVER_ADDR"]127.0.0.1
_SERVER["SERVER_PORT"]80
_SERVER["REMOTE_ADDR"]127.0.0.1
_SERVER["DOCUMENT_ROOT"]D:/Program Files/Apache/htdocs
_SERVER["SERVER_ADMIN"]admin@example.com
_SERVER["SCRIPT_FILENAME"]D:/Program Files/Apache/htdocs/index.php
_SERVER["REMOTE_PORT"]5007
_SERVER["GATEWAY_INTERFACE"]CGI/1.1
_SERVER["SERVER_PROTOCOL"]HTTP/1.1
_SERVER["REQUEST_METHOD"]GET
_SERVER["QUERY_STRING"]no value
_SERVER["REQUEST_URI"]/
_SERVER["SCRIPT_NAME"]/index.php
_SERVER["HP_SELF"]/index.php
_SERVER["REQUEST_TIME"]1333896762

PHP License
This program is free software; you can redistribute it and/or modify it under the terms of the PHP License as published by the PHP Group and included in the distribution in the file:  LICENSE
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact license@php.net.

 楼主| 发表于 2012-4-8 22:54:42 | 显示全部楼层
麻烦十六进制帮忙看看, 我试了早点版本没有问题,但是早期版本的多工程共享ci有问题。
发表于 2012-4-9 10:40:03 | 显示全部楼层
看起来你的配置没什么问题。
你把那句有问题的 PHP 代码注释就可以了,不用费这么大的劲,都是开源项目可以随便改。
 楼主| 发表于 2012-4-9 10:52:45 | 显示全部楼层
哦 谢谢了, 因为对ci不是太熟悉,第一次用,怕因为修改一点源代码会造成其他想不到的问题。
那我先试试注释掉有问题的代码,有问题再想你请教,谢谢你的回复。。

本版积分规则