Active Record Pattern
Khanh is a full stack web developer with over 15 years of experience developing for the web
Search for a command to run...
Khanh is a full stack web developer with over 15 years of experience developing for the web
No comments yet. Be the first to comment.
Elevate your bus reservation experience (or even movie, theater, train, ship, plane tickets) with the React Bus Seat Map Picker – a sophisticated and meticulously crafted script designed exclusively for bus seat bookings. Engineered with strict TypeS...

In previous blog, I migrated all posts from my WordPress to Hashnode at https://blog.donamkhanh.com. Now I create a simple landing page for my main domain and hosted on Github Page. You can access at https://donamkhanh.com. In feature, I'm going to h...

I just finished migrating my blog from Wordpress (self hosted on DigitalOcean) to Hashnode. How did I migrate? I don't have too many articles on Wordpress but I don't like doing it manually so the first thing I did was look to see if there was an aut...

Dự án mình đang làm có yêu cầu sử dụng Azure Active Directory (AAD) để lưu trữ thông tin người dùng & xác thực đăng nhập các kiểu. Ngoài các trường thông tin cơ bản mà AAD hỗ trợ ra thì dự án mình cần lưu thêm 1 số thông tùy chọn khác cho người dùng....

Introduction This is a concise front-end application developed with Angular. You can create a beautiful form with drag and drop visualization. You can get inspiration from it to make a draggable form; at the same time, you can also modify it to suit ...

From Wikipedia, the free encyclopedia
In [computer science](http://en.wikipedia.org/wiki/Computer_science "Computer science"), the active record pattern is a [design pattern](http://en.wikipedia.org/wiki/Designpattern%28computer_science%29 "Design pattern (computer science)") frequently found in software that stores its data in [relational databases](http://en.wikipedia.org/wiki/Relational_database "Relational database"). It was named by [Martin Fowler](http://en.wikipedia.org/wiki/Martin_Fowler "Martin Fowler") in his book Patterns of Enterprise Application Architecture.
Active record is an approach to accessing data in a [database](http://en.wikipedia.org/wiki/Database "Database"). A [database table](http://en.wikipedia.org/wiki/Databasetable "Database table") or [view](http://en.wikipedia.org/wiki/View%28database%29 "View (database)") is wrapped into a [class](http://en.wikipedia.org/wiki/Class_%28computerscience%29 "Class (computer science)"), thus an [object](http://en.wikipedia.org/wiki/Object%28computer_science%29 "Object (computer science)") instance is tied to a single row in the table. After creation of an object, a new row is added to the table upon save. Any object loaded gets its information from the database; when an object is updated, the corresponding row in the table is also updated. The [wrapper class](http://en.wikipedia.org/wiki/Wrapper_class "Wrapper class") implements [accessor](http://en.wikipedia.org/wiki/Accessor "Accessor") [methods](http://en.wikipedia.org/wiki/Methods "Methods") or properties for each column in the table or view.
This pattern is commonly used by object persistence tools, and in [object-relational mapping](http://en.wikipedia.org/wiki/Object-relational_mapping "Object-relational mapping"). Typically [foreign key](http://en.wikipedia.org/wiki/Foreign_key "Foreign key") relationships will be exposed as an object instance of the appropriate type via a property.
Implementations of Active Record can be found in various [frameworks](http://en.wikipedia.org/wiki/Framework "Framework") for many programming environments. For example, if in a database there is a table parts with columns name (string type) and price (number type), and the Active Record pattern is implemented in the class Part, the following pseudo-code:
part = new Part() part.name = "Sample part" part.price = 123.45 part.save()
will create a new row in the parts table with the given values, and is roughly equivalent to the [SQL](http://en.wikipedia.org/wiki/SQL "SQL") command
INSERT INTO parts (name, price) VALUES('Sample part', 123.45);
Conversely, the class can be used to query the database:
b = Part.find_first_part("name", "gearbox")
This will create a new Part object based on the first matching row from the parts table whose name column has the value "gearbox". The SQL command used would be
SELECT * FROM parts WHERE name = 'gearbox' LIMIT 1;
Để đó, chưa dịch :(