• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extending model

I found an interesting scenario and please help me to see whether it is an issue.
I defined the table as following:

int AI PK
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 = [

    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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.