Mo *_*tch 3 php postgresql laravel eloquent laravel-4
在发布之前我做了很多研究.
尝试使用Laravel eloquent ORM将记录插入PostgreSQL时,我收到以下错误.
这是错误:
Illuminate \ Database \ QueryException
SQLSTATE[42703]: Undefined column:
7 ERROR: column "id" does not exist LINE 1: ...ed_at", "created_at")
values ($1, $2, $3, $4)
returning "id" ^ (SQL: insert into "fb_post_like_counts" ("post_id", "count", "updated_at", "created_at") values (293843523498_10152007721598499, 0, 2014-03-12 16:56:24, 2014-03-12 16:56:24) returning "id")
Run Code Online (Sandbox Code Playgroud)
这是数据库表创建模式:
Schema::create('fb_post_shares_counts', function($table)
{
//
$table->string('post_id');
$table->string('count')->default(0);
// created_at updated_at deleted_at
$table->timestamps();
$table->softDeletes();
// set composite keys
$table->primary(array('post_id', 'updated_at'));
});
Run Code Online (Sandbox Code Playgroud)
这是我试图执行的代码:
// SAVE POST SHARES
$post_share_count = new FbPostShareCount;
$post_share_count->post_id = $response['id'];
$post_share_count->count = $fql_post['share_count'];
$post_share_count->save();
Run Code Online (Sandbox Code Playgroud)
我创建了一个模型类FbPostShareCount扩展了Eloquent.
我知道laravel不支持复杂的密钥,但是当我使用MySQL时没有出现这个问题
将FbPostShareCount模型中的主键设置为
class FbPostShareCount extends Eloquent {
protected $primaryKey = 'post_id';
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8381 次 |
| 最近记录: |