CodeIgniter Forums

Full Version: new feature Entity ci4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when  has an entity for model  , if we use $datamap[] in our entity 
$model->find() it be like  data via ReturnType Entity 
model update or save   have to  use  $datamap[]  for it operation  
okay
but  when  we use $datamap for  $model->where() or $model->like() or $model->whereIn()
it  dose not follow $datamap[] so  we get error  it should be both for $datmap or  data base coulmn schema 
see    codes 

PHP Code:
class  Entity extends Entity
{


    protected $id;
    protected $name;
    protected $link;
  


    
protected $attributes = [
        'id' => null,
        'name' => null,
        'user_id' => null,
      
    
];
    protected $datamap = [
 
'userId' =>'user_id',
      
    
];

    protected $dates = ['created_at''updated_at''deleted_at'];

    protected $casts = [
      
    
];

    protected $permissions = [];

    protected $roles = [];

  

  

}

$entity = new Entity()

$model=  new Model();

$model->save($entity);
$model->update($id,$entity);

// but this no gonna work  and get error 
// it dose not recognize $datamap[]
$model->select('*')->where(['userId'=>'2')->find();

// th orginal one works         
$model->select('*')->where(['user_id'=>'2')->find();

// do you see ?!!!!!!!!!!! 
// we need this new feature