Wiki

Articles tagged with "active record", sorted by commentsX
Displaying 1-10 of 17 result(s).

Searching and sorting by related model in CGridView

Created 6 years ago by Maciej LiżewskiTutorials86 comments – viewed 201,693 times – ( +126 / -1 ) – version 1.1
Lets say we have two models and relation between them:

Increasing AR performance in connections with Oracle

Created 7 years ago by TrejderHow-tos14 comments – viewed 26,504 times – ( +2 / -1 ) – version 1.1
Please, note. This article is entirely based on a work done by me colleague developer, who hasn't got account on this webpage and also hasn't got time for writing this article. I'm writing it for him. I will try to forward him any comments that may appear, but can't assure if/when he'll be able to answer. I'm far, far less experienced in Oracle therefore I won't probably be able to help myself.

Accessing data in a join table with the related models

Created 6 years ago by fsbHow-tos8 comments – viewed 115,586 times – ( +28 / -2 ) – version 1.1
Sometimes the right place to store application data is in a join table. For example, movie viewers either like or don’t like the movies they watched.

Single table inheritance

Created 6 years ago by samdarkHow-tos8 comments – viewed 38,553 times – ( +41 / -1 ) – version 1.1
Relational databases do not support inheritance so if we need to represent it, we have to somehow store meta info while keeping performance by minimizing JOINs. One way to solve this problem is using single table inheritance. All fields for the whole class tree are stored in a single table. Class name is stored in the type field of the same table.

1:n relations sometimes require CDbCriteria.together

Created 6 years ago by fsbTips5 comments – viewed 40,178 times – ( +16 / -1 ) – version 1.1
There are situations in which Active Record will generate nonsense queries from what a nieve Yii user might think is reasonable code. One such situation is a CActiveDataProvider using CDbCriteria to get data from parent and 1:n child table with a condition on the child table.

Active Record snapshotting (Model data base history)

Created 2 years ago by BizleyTutorials3 comments – viewed 8,050 times – ( +2 / -1 ) – version 1.1
One of the common tasks the web application might be required to perform, especially the app using some kind of a CMS, is to save the history of data changes. Your client for sure will want the answer to this simple question - If I mess this up or delete by accident can we bring it back? Well, DB backup is one thing and quick recovery is another - let's talk about latter one.

Using sub query for doubletts

Created 5 years ago by mbTips3 comments – viewed 14,321 times – ( +2 / -1 ) – version 1.1
find doubletts by db fields. in this example i will check doublets for 3 tabelfields (col1,col2,col3). so i will get a subquery with the condition, select and grouping of the tablefields. the having with COUNT() > 1 means: find all records more then one result.

A simple class to use a different db for a module

Created 6 years ago by tydeas_drTips3 comments – viewed 19,595 times – ( +10 / -1 ) – version 1.1
What would you do if you want/need to have a different than the main database connection in an module's models?

Extending an ActiveRecord model

Created 4 years ago by BogseyHow-tos3 comments – viewed 18,386 times – ( +2 / -4 ) – version 1.1
Introduction

A universal model attribute for its synthetic representation

Created about a year ago by Alexandre RodichevskiTips2 comments – viewed 4,569 times – ( -1 ) – version 2.0
It is convenient to use the same identification attribute, say info, in all of the active records of your application. It should be a virtual read-only attribute defined by a getter method, its label being the model name.