active-record

What is Active Record in Yii2?

Active Record is database access and manipulation tool that uses an object-oriented interface. An Active Record class is linked to a database table, an Active Record instance is linked to a table row, and an attribute of an Active Record instance is linked to the value of a specific column in that row. To access and alter the data stored in database tables, you would access Active Record properties and invoke Active Record methods instead of writing raw SQL commands.

What is Yii2's character?

The Yii base Behavior class is used to create behaviours. A behaviour attaches itself to a component and injects its methods and properties into it. Behaviour patterns can also react to the events that the component has caused.

What should you do if a Yii DB exception is thrown?

Sets a callable (e.g., an anonymous function) that is called when the yii\\db\\Exception is thrown during the command execution. The callable’s signature should be: The default fetch mode for this command is the DB connection with which it is linked.

For data access, Active Record provides an object-oriented API. A database table is connected with an Active Record class.

Active Record support is available in Yii for the following relational databases:

You should follow these steps to query data from a separate database table after establishing an Active Record class (in our example, the user model).

Conclusion

I hope you found this guide helpful in understanding Active Record in Yii2. XcelTec can help you with your projects by providing Virtual Developers.

Get in touch with us for more!

Contact us on:- +91 987 979 9459 | +1 919 400 9200
Email us at:- sales@xceltec.com

Leave A Comment

Your email address will not be published.

XcelTec's Blog