Gla*_*ats 5 php sql-server sql-server-2008 laravel-4
我在SQL Server 2008中使用laravel 4.1
我基于带有时间戳的雄辩orm创建了一个模型:
class Attendance extends \Eloquent {
protected $table = 'Attendance';
public function users(){return $this->belongsToMany('User', 'Users_Attendance', 'user_id', 'attendance_id');}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试插入新字段时:
public function postAttendanceUsers() {
$attendance = new Attendance;
$attendance->user_id = Auth::user()->id;
$attendance->save();
}
Run Code Online (Sandbox Code Playgroud)
显示以下错误:
SQLSTATE [22007]:[Microsoft] [用于SQL Server的ODBC驱动程序11] [SQL Server]将varchar数据类型转换为日期时间数据类型会导致值超出范围。(SQL:插入[考勤]([user_id],[updated_at],[created_at])值(40,2015-08-27 12:28:42.000,2015-08-27 12:28:42.000))
我创建了一个具有以下格式的新方法:
/**
* Get the format for database stored dates.
*
* @return string
*/
public function getDateFormat() {
return 'Y-d-m H:i:s';
}
Run Code Online (Sandbox Code Playgroud)
我希望有人有用