$customers = Customer::model()->findAll(); foreach($customers as $customer) { echo $customer->name; }
$customer = new Customer; $customer->name = "John Doe"; $customer->email = "john@example.com"; $customer->save();
$customer = Customer::model()->findByPk(1); $customer->email = "jane@example.com"; $customer->save();
$customer = Customer::model()->findByPk(2); $customer->delete();This code fetches a record with primary key value 2 and deletes it. `CActiveRecord` is a part of Yii Framework's `db` package library which provides database access functionality including query builders, query caching and ActiveRecord implementation.