Laravel & freetds 无法向 mssql 中插入数据
Laravel & freetds can't insert data into mssql
我只需要将数据(字符集 UTF-8)插入 mssql table。我可以 select 数据,但不能插入。
为了通过 laravel 连接到 mssql 服务器,我使用 "Freetds"。
Laravel 4.2
插入代码:
try {
$data = DB::table('angularTableUserData')->insert([
'userId' => Auth::user()->PK_psPersonalData,
'fullname2' => $data['fullname2'],
'praddress' => $data['praddress'],
'occupation' => $data['occupation'],
'gender' => $data['gender'],
'prtelno' => $data['prtelno'],
'mobilephone' => $data['mobilephone'],
'emptelefax' => $data['emptelefax'],
'email' => $data['email'],
'promo' => $data['promo'],
'nkfullname' => $data['nkfullname'],
'FK_mscRelation_NK' => $data['FK_mscRelation_NK'],
'nktelefax' => $data['nktelefax'],
'civilstatus' => $data['civilstatus'],
'otherallergies' => $data['otherallergies'],
'pastmedallergy' => $data['pastmedallergy']
]);
}
catch(Exception $ex)
{
return $ex;
}
return $data;
错误文本:
http://pastebin.com/eUabMPCP
Table结构
[id] [int] IDENTITY(1,1) NOT NULL,
[userId] [int] NULL,
[fullname2] [varchar](max) NULL,
[praddress] [varchar](max) NULL,
[occupation] [varchar](max) NULL,
[gender] [varchar](max) NULL,
[prtelno] [varchar](max) NULL,
[mobilephone] [varchar](max) NULL,
[emptelefax] [varchar](max) NULL,
[email] [varchar](max) NULL,
[promo] [varchar](max) NULL,
[nkfullname] [varchar](max) NULL,
[nktelefax] [varchar](max) NULL,
[civilstatus] [varchar](max) NULL,
[pastmedallergy] [varchar](max) NULL,
[otherallergies] [text] NULL,
好的,我终于解决了。
忘记了默认的 laravel 时间戳并且错误没有显示它。
刚刚添加:
public $timestamps = false;
在代码中。
我只需要将数据(字符集 UTF-8)插入 mssql table。我可以 select 数据,但不能插入。
为了通过 laravel 连接到 mssql 服务器,我使用 "Freetds"。
Laravel 4.2
插入代码:
try {
$data = DB::table('angularTableUserData')->insert([
'userId' => Auth::user()->PK_psPersonalData,
'fullname2' => $data['fullname2'],
'praddress' => $data['praddress'],
'occupation' => $data['occupation'],
'gender' => $data['gender'],
'prtelno' => $data['prtelno'],
'mobilephone' => $data['mobilephone'],
'emptelefax' => $data['emptelefax'],
'email' => $data['email'],
'promo' => $data['promo'],
'nkfullname' => $data['nkfullname'],
'FK_mscRelation_NK' => $data['FK_mscRelation_NK'],
'nktelefax' => $data['nktelefax'],
'civilstatus' => $data['civilstatus'],
'otherallergies' => $data['otherallergies'],
'pastmedallergy' => $data['pastmedallergy']
]);
}
catch(Exception $ex)
{
return $ex;
}
return $data;
错误文本: http://pastebin.com/eUabMPCP
Table结构
[id] [int] IDENTITY(1,1) NOT NULL,
[userId] [int] NULL,
[fullname2] [varchar](max) NULL,
[praddress] [varchar](max) NULL,
[occupation] [varchar](max) NULL,
[gender] [varchar](max) NULL,
[prtelno] [varchar](max) NULL,
[mobilephone] [varchar](max) NULL,
[emptelefax] [varchar](max) NULL,
[email] [varchar](max) NULL,
[promo] [varchar](max) NULL,
[nkfullname] [varchar](max) NULL,
[nktelefax] [varchar](max) NULL,
[civilstatus] [varchar](max) NULL,
[pastmedallergy] [varchar](max) NULL,
[otherallergies] [text] NULL,
好的,我终于解决了。
忘记了默认的 laravel 时间戳并且错误没有显示它。
刚刚添加:
public $timestamps = false;
在代码中。