我关注了this (法语)和 this在 CodeIgniter 3 应用程序中使用 Eloquent 的教程。
选择方法按预期工作,即使有关系,但插入/更新方法不起作用,也不返回任何错误。我搜索过类似的问题,但无法解决我的问题,所以我希望有人能帮助我。
我的模特之一:
<?php
require_once('Eloquent.php');
use \Illuminate\Database\Eloquent\Model as Eloquent;
class User extends Eloquent {
//Eloquent vars
public $table = "app_users";
protected $primaryKey = "id";
public $timestamps = false;
}
返回 1 但实际上并未将数据插入数据库的插入:
$client = new User;
$client->id = $id;
$client->username = 'username';
$client->first_name = 'first_name';
$client->last_name = 'last_name';
$client->mail = 'mail';
$result = $client->save();
插入默默失败...任何提示将不胜感激,无论是关于如何解决这个问题还是调试它! find()、all() 等方法再次运行良好,因此 Eloquent 似乎可以正常运行...
最佳答案
感谢Paul Spiegel指出我需要修改异常模式(我错过了导致插入/更新失败的数据库迁移)
关于php - Codeigniter/Eloquent 选择但不插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45718350/