此模型行为不正确。它没有填写它的属性,也不能拨打find()
,get()
或任何类型的吸气剂。创建和获取模型的错误
这里是它的create_matches_table:
public function up()
{
Schema::create('matches', function (Blueprint $table) {
$table->increments('id');
$table->integer('p1');
$table->integer('p2');
$table->integer('u1');
$table->integer('u2');
$table->string('p1_action')->nullable();
$table->string('p2_action')->nullable();
$table->bigInteger('clock')->unsigned();
$table->smallinteger('round')->unsigned()->default('1');
$table->integer('victor')->nullable();
$table->boolean('murder');
$table->integer('wager')->unsigned()->nullable();
$table->integer('notoriety')->nullable();
$table->integer('stalemate')->default('0');
$table->timestamps();
$table->datetime('finished_at')->nullable();
});
}
使用Match::create($data)
其中$data
是属性的数组完美排队与那些需要将不会填充它们返回的对象从不具有clock
属性如上述所希望的。
public static function setMatch($data)
{
$match = new Match;
$match->fill($data);
$match->clock = time() + 6;
$match->save();
return $match;
}
即使是在这样做,试图让这个对象由$match = Match::find([$id])->first();
的特定记录产生这个错误:
SQLSTATE[HY000]: General error: 2031 (SQL: select * from
matches
wherematches
.id
in (?)) in Connection.php line 729
at
> Connection->runQueryCallback('select * from `matches` where
> `matches`.`id` in (?)', array(), object(Closure)) in Connection.php
> line 685 at Connection->run('select * from `matches` where
> `matches`.`id` in (?)', array(), object(Closure)) in Connection.php
> line 349 at Connection->select('select * from `matches` where
> `matches`.`id` in (?)', array(), true) in Builder.php line 1610
我已经勉强通过绕行这些问题我尝试了硬编码值,将它作为一个数组传递,甚至只是为了Match::first()
,并且都返回这个错误。
所有我需要的是为此作为一个常规的醇模型。
你配置你的数据库设置吗? –