Extending model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Extending model (/showthread.php?tid=75959) |
Extending model - windyboy911 - 03-31-2020 I found an interesting scenario and please help me to see whether it is an issue. I defined the table as following: Table:t_orderinfo Columns: id int AI PK order_id varchar(100) PK payment_status int company_id varchar(100) payment_amount decimal(10,2) create_time datetime update_time datetime And I defined my entity class Order extends Entity { protected $attributes = [ 'order_id' => null, // Represents a username 'company_id' => null, 'payment_amount' => null, 'payment_status' => null ]; } And my Model class OrderModel extends Model { protected $DBGroup = 'default'; protected $table = 't_orderinfo'; protected $primaryKey = 'id'; protected $returnType = 'App\Entities\Order'; protected $useSoftDeletes = false; protected $allowedFields = [ 'order_id', 'payment_status', 'company_id', 'payment_amount' ]; protected $useTimestamps = true; protected $createdField = 'create_time'; protected $updatedField = 'update_time'; protected $validationRules = []; protected $validationMessages = []; protected $skipValidation = false; } And wired thing is , when set the primaryKey as id, I can successfully save the record, but when I use order_id as my PK, the save method also return true, but there is no record in the database. Is there anyone can support me? RE: Extending model - jreklund - 04-01-2020 Hi, I split your post into it's own thread. As the thread you choose where about the Codeigniter.com website, and not support on the actual software. |