Wiki

Articles tagged with "active record", sorted by viewsX
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,643 times – ( +126 / -1 ) – version 1.1
Lets say we have two models and relation between them:

Accessing data in a join table with the related models

Created 6 years ago by fsbHow-tos8 comments – viewed 115,538 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.

1:n relations sometimes require CDbCriteria.together

Created 6 years ago by fsbTips5 comments – viewed 40,165 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.

Single table inheritance

Created 6 years ago by samdarkHow-tos8 comments – viewed 38,538 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.

Increasing AR performance in connections with Oracle

Created 6 years ago by TrejderHow-tos14 comments – viewed 26,489 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.

Debugging CActiveRecord failed save() attempts

Created 4 years ago by BoazTips0 comments – viewed 24,020 times – ( +5 / -1 ) – version 1.1
When you're filling up a form of a CActiveRecord (using CActiveForm for example), usually you'll construct your code so that in case of validation error you'll get back the form with the error displayed back to you, typically when CActiveForm.errorSummary() is used. This is how its done by Gii.

A simple class to use a different db for a module

Created 6 years ago by tydeas_drTips3 comments – viewed 19,589 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,379 times – ( +2 / -4 ) – version 1.1
Introduction

Using sub query for doubletts

Created 5 years ago by mbTips3 comments – viewed 14,316 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.

How to avoid a database update if the ActiveRecord was not modified

Created 3 years ago by tomvdpHow-tos0 comments – viewed 12,039 times – ( +1 / -1 ) – version 1.1
The classic Yii way for doing an update action is as follows: