1. 程式人生 > >ThinkPHP 連線 sql server 返回日期格式 object TO string

ThinkPHP 連線 sql server 返回日期格式 object TO string

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);