雄辩的创造不起作用

时间:2014-05-30 22:08:59

标签: php laravel laravel-4

使用Eloquent在表格中创建时遇到问题:

| id    | url         | shortened |
| 1     | website.com | asdf      |

所以我想插入一个新的URL,所以我创建了一个扩展Eloquent的新模型然后我写了这个:

$row = Url::create(array('url' => $url, 'shortened' => $shortened));
if ($row) {
    $both = array('url' => $url, 'shortened' => $row->shortened);
    return View::make('home.result', $both);
}

但是当我尝试它时,就会出现问题:"哎呀,看起来出了问题。" 在那之后,我尝试了一种新的方式:

$new_u = new Url();
$new_u->url = $url;
$new_u->shortened = $shortened;
$new_u->save();

在Url课程中使用此功能:

protected $table = 'urls';
protected $fillable = array('url', 'shortened');

同样的问题!

0 个答案:

没有答案