-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add dbgroup to model template only when specified as an option #8077
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I personally prefer $DBGroup
to be like this when creating the model.
protected $DBGroup = null;
The reason for this is in the visibility of this property for rapid change during development.
However, this is a personal opinion.
@datamweb I don't know what you exactly means by rapid change during development, but I feel strange that writing And more than 90% devs use single db group, I guess. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine, but wait for other people's opinions.
Imagine that the model is make as follows. <?php
namespace App\Models;
use CodeIgniter\Model;
class Sample extends Model
{
protected $table = 'Sample';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [];
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
} Do you realize that there are Validation or Callbacks? No, you must see the documents. <?php
namespace App\Models;
use CodeIgniter\Model;
class Sample extends Model
{
protected $table = 'Sample';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [];
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
} As a beginner in CodeIgniter, I prefer to have everything in front of my eyes so that I can be aware of the existence of this feature and be curious. Not that I have to constantly read the documentation or even not know about many features. This is very important for me, who is not an English speaker.
I agree with you on this. |
For me, I don't want code to clutter when I don't have a need for them. Just the needed code to run. |
cbab757
to
23eb997
Compare
@sammyskills Thank you! |
Description
The property
$DBGroup
should only be added to the generated model template when specified as an option:--dbgroup
.Fixes #8073
Checklist: