Extending model |
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?
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.
|
Welcome Guest, Not a member yet? Register Sign In |