Yii ActiveRecord definitely makes programming easier with regards to the database, as of course, any decent implementation of ActiveRecord does.
Display on db
Regarding the mapping between the database and your models, there is no problem that your code will βcaptureβ your database. The only thing you need to constantly support is the following:
public function tableName() { return 'my_table'; }
Seeing that the table names will not change frequently does not have practical significance.
There are other parts of your ActiveRecord models that should stay in sync with your circuit:
- Phpdoc comments describing model class properties
- Other public functions that implement various bits of functionality, such as validation rules [
public function rules() ], external model relations [ public function relations() ], attribute labels [ public function attributeLabels() ], etc.
However, you can still use the models and the database itself, even if they do not reflect your current database schema - just that the corresponding bits of functionality will no longer work.
These pieces of data do not apply the limitations of your database, they simply help you, allowing you to access functions in a more intuitive way. Actual restrictions are still implemented in the database.
Performance
Yii implements a query builder that you can use to generate SQL from freely expressed expressions (your models use the same mechanism when directly querying). The builder generates SQL from freely expressed expressions, and the result will not be slower than if you were executing equivalent SQL directly.
Of course, using the query builder itself will cause some overhead, but this is a compromise that has been largely chosen for all modern programming languages ββ(LINQ will be the most massive example here), because it's worth it.
In any case, you can write SQL queries CDbCommand using CDbCommand . I see no reason for this, but there is always an option if you need it. Therefore, there is no chance that you will remain unsatisfactory in ActiveRecord, no matter what you need to do.