SQLSTATE [23000]:完整性约束违规

时间:2016-05-10 17:36:34

标签: sql angularjs

好的,所以我试图在我的团队中添加一个新团队'我的数据库上的列,但是我收到此错误[QueryException"," message":" SQLSTATE [23000]:完整性约束违规:1048列' name'不能为空(SQL:插入teamsnamegame)]

这是HTML -

<form ng-submit="addteam()" ng-model="teamform">
            <h2>Add Team</h2>
            <label>
                Team Name 
                <input type="text" ng-model="teamform.name"/>
            </label>
            <label>
                Game
                <select ng-model="teamform.game">
                    <option ng-repeat="game in games" value="{{game.gameID}}">{{game.game_name}}</option>
                </select>
            </label>
            <input value="submit" type="submit"/>
        </form>

这是服务 -

addteam:function(form){
            var call = Phone.call('api/team/insert', form);
            call.success(function(data) {
                Flash.show('Team Created');
            });
            call.error(function() {
            });

            return call;
        }

这是控制器 -

$scope.addteam = function(){
        PanelService.addteam($scope.teamform);
    };

这是TeamController -

public function insertTeam(){
        Team::insertGetId(array(
            'name'=>Input::get('name'),
            'game'=>Input::get('game')
        ));
    }

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

尝试在控制器中添加此内容

$scope.teamform = {}