【发布时间】:2014-12-12 13:21:34
【问题描述】:
我有 FotoController.php
这是功能的一部分:
$img = array(
'name' => $filename,
'gid' => $id,
);
$s = new Img($img);
$create = $s->save();
我的 img 模型:
class Img extends Eloquent {
public $timestamps = false;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'images';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
//protected $hidden = array('remember_token');
protected $fillable = array('name', 'gid', 'views', 'likes');
}
但它不会将新记录添加到数据库中。
【问题讨论】:
-
你可以像这样使用create方法;
Img::create($img); -
你能给我举个例子吗?
-
阅读评论,您会找到示例...