Home > php教程 > php手册 > 解决MSSQL2008 datetime字段在thinkphp模板输出问题

解决MSSQL2008 datetime字段在thinkphp模板输出问题

WBOY
Release: 2016-06-07 11:41:24
Original
986 people have browsed it

今天做个项目发现连接sql2008后,dump出来的datetime字段不是想要的,无法在模板中直接volist出来,查阅函数找到了解决方法!
未处理的dump信息

解决MSSQL2008 datetime字段在thinkphp模板输出问题

get_object_vars()处理后的dump信息

解决MSSQL2008 datetime字段在thinkphp模板输出问题

使用方法

在你的datetime变量使用get_object_vars($time)就可以了,然后在模板中使用多数组循环显示就可以了!
=============================最新解决方法=======
ThinkPHP 自带的sqlsrv类库,查询返回的日期类型是object,要取得string类型的话,要改动Thinkphp\Library\Think\Db\Driver\Sqlsrv.class.php文件,$connectInfo  =  array('Database'=>$config['database'],'UID'=>$config['username'],'PWD'=>$config['password'],'CharacterSet' => C('DEFAULT_CHARSET'));  改为 $connectInfo  =  array('Database'=>$config['database'],'UID'=>$config['username'],'PWD'=>$config['password'],'CharacterSet' => C('DEFAULT_CHARSET'), 'ReturnDatesAsStrings'=> true);

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template