test编码为Latin1_General_BIN
test2编码为Chinese_PRC_CI_AS
版本:ThinkPHP3.2.3
数据库:sqlserver 2008 r2
common.php
DB_NAME为test时报错,改成test2就能正常输出数据。
<?php
return array(
//'配置项'=>'配置值'
'DB_TYPE' => 'sqlsrv', // 数据库类型
'DB_HOST' => '127.0.0.1', // 服务器地址
'DB_NAME' => 'test', // 数据库名
'DB_USER' => 'sa', // 用户名
'DB_PWD' => '111@xxx', // 密码
'DB_PORT' => '1433', // 端口
'DB_PREFIX' => '', // 数据库表前缀
'DB_CHARSET' => 'utf-8', // 数据库编码
'DB_DEBUG' => TRUE, // 数据库调试模式 开启后可以记录SQL日志
);IndexController<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$data = M("Table_1");
$list = $data->limit(10)->select();
echo "<pre>";
print_r($list);
}
}下面为报错信息::(
SQLSTATE[42S02]: [Microsoft][SQL Server Native Client 11.0][SQL Server]对象名 'information_schema.tables' 无效。
错误位置
FILE: E:\www\ThinkPHP\Library\Think\Db\Driver.class.php LINE: 169
TRACE
#0 E:\www\ThinkPHP\Library\Think\Db\Driver.class.php(169): PDOStatement->execute()
#1 E:\www\ThinkPHP\Library\Think\Db\Driver\Sqlsrv.class.php(56): Think\Db\Driver->query('SELECT column...')
#2 E:\www\ThinkPHP\Library\Think\Model.class.php(134): Think\Db\Driver\Sqlsrv->getFields('table_1')
#3 E:\www\ThinkPHP\Library\Think\Model.class.php(122): Think\Model->flush()
#4 E:\www\ThinkPHP\Library\Think\Model.class.php(1434): Think\Model->_checkTableInfo()
#5 E:\www\ThinkPHP\Library\Think\Model.class.php(97): Think\Model->db(0, '', true)
#6 E:\www\ThinkPHP\Common\functions.php(621): Think\Model->__construct('Table_1', '', '')
#7 E:\www\Application\Home\Controller\IndexController.class.php(7): M('Table_1')
#8 [internal function]: Home\Controller\IndexController->index()
#9 E:\www\ThinkPHP\Library\Think\App.class.php(164): ReflectionMethod->invoke(ob
#10 E:\www\ThinkPHP\Library\Think\App.class.php(202): Think\App::exec()
#11 E:\www\ThinkPHP\Library\Think\Think.class.php(120): Think\App::run()
#12 E:\www\ThinkPHP\ThinkPHP.php(97): Think\Think::start()
#13 E:\www\index.php(24): require('E:\www\ThinkPHP...')
#14 {main}
ThinkPHP3.2.3 { Fast & Simple OOP PHP fr
最佳答案