【发布时间】:2015-01-19 19:45:29
【问题描述】:
我需要使用 laravel 将一个简单的表单数据添加到数据库中
每次表单发布时,数据都会进入数据库,但我收到此错误
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tf.FirstName' in 'field list' (SQL: insert into `tbl_fundraising_pages` (`Permalink`, `Name`, `Summary`, `Story`, `Goal_Amount`, `End_Date`, `Designation`, `WebAddress`, `Block_SearchEngine`, `CharityID`, `updated_at`, `created_at`) values (Something-Like-That, Something Like That, Something Like That, <p>Something Like That</p> , 500, 11/04/2014, General Fund, Something-Like-That, NewDesig, 1387, 2014-11-21 15:14:19, 2014-11-21 15:14:19)
数据库中没有 tf.FirstName 字段,查询也没有 模态
<?php
class Fundraising extends Eloquent{
protected $table = 'tbl_fundraising_pages';
protected $fillable = [
'fundraiser_id',
'Permalink',
'Name',
'Summary',
'Story',
'Goal_Amount',
'End_Date',
'Designation',
'WebAddress',
'Block_SearchEngine',
'CharityID'
];
}
控制器功能
public function postCreatePage(){
$charities = Charities::where('Charity_Name','=',''.Input::get('NonprofitName').'')->first();
$data = array(
'Permalink' => str_replace(' ', '-', Input::get('FundraiserName')),
'Name' => Input::get('FundraiserName'),
'Summary' => Input::get('Summary'),
'Story' => Input::get('YourPassion'),
'Goal_Amount' => Input::get('GoalAmount'),
'Designation' => Input::get('Designation'),
'WebAddress' => str_replace(' ', '-', Input::get('FundraiserName')),
'Block_SearchEngine' => Input::get('NewDesig')
);
if(Input::get('NonprofitName')){
$data['CharityID'] = $charities->ID;
}
$page = new Fundraising();
foreach ($data as $key => $insert){
$page->$key = $insert;
}
if($page->save()){
return Response::json(array('message' => 'Done'));
}
}
我不知道这个文件是从哪里来的?
HTML 表单中没有任何内容 在 Ajax 调用中没有任何内容
【问题讨论】:
-
有没有可能是某种 SQL 触发器导致了这种情况?
-
我没有使用任何 SQL 触发器
-
你的迁移是什么?