Wiki articles tagged with "model"

Showing 1-20 of 28 items.

Single table inheritance

Created 14 years ago by samdark samdark, updated 14 years ago by samdark samdark.

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...

34 0
35 followers
Viewed: 56 295 times
Version: 1.1
Category: How-tos

Search method of a model for filters when using dates - unixtimestamp in database

Created 15 years ago by Mukke Mukke, updated 14 years ago by jwerner jwerner.

I ran into a problem and on irc we worked it out. Since there is a lack on information on filters in genral i thought i'd start sharing all my findings, might be usefull for other people.

10 0
11 followers
Viewed: 40 049 times
Version: 1.1
Category: Tips

Application-driven database with CDbMigration and an extended CActiveRecord

Created 14 years ago by Tudor Ilisoi Tudor Ilisoi, updated 14 years ago by Tudor Ilisoi Tudor Ilisoi.

This is an incipient implementation of application-driven database with Yii.

8 0
10 followers
Viewed: 18 220 times
Version: 1.1
Category: Others

Managing constants easily

Created 14 years ago by briiC.lv briiC.lv, updated 14 years ago by briiC.lv briiC.lv.

/*

    Get class constants by token.
    If you set constants with same prefix, like:
	MY_STATUS_1
	MY_STATUS_2
	MY_STATUS_3
4 0
7 followers
Viewed: 34 072 times
Version: 1.1
Category: Tips

Update two models with one view

Created 14 years ago by sensorario sensorario, updated 13 years ago by SebK SebK.

Suppose to have two models: Users and Emails. You do not want to store email in a Users model. And User can have 0 or many emails. This is the form generated to create a new user (just username).

9 3
13 followers
Viewed: 59 059 times
Version: 1.1
Category: Tips

Inline views, write less

Created 12 years ago by Firebreaker Firebreaker, updated 12 years ago by Firebreaker Firebreaker.

Sometimes writing views like

3 0
3 followers
Viewed: 13 213 times
Version: Unknown (update)
Category: Tips

model rules depended by user roles-permissions

Created 12 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 12 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

This is a reference about model validators and user roles. In many cases we want model validators to applied only for some privileged users or not

3 0
3 followers
Viewed: 21 384 times
Version: Unknown (update)
Category: How-tos

How to preload dropdowns in CForm

Created 12 years ago by transistor transistor, updated 12 years ago by transistor transistor.

So you want to use CForm (form builder), but need to preload dropdowns in a form? It's simpler than it seems.
You got your CFormModel, CForm and the actual Form, right?
Let's say you have the typical State -> City dependent dropdowns, so you would want to load the from with the State and City selected.

1 0
2 followers
Viewed: 13 846 times
Version: Unknown (update)
Category: Tips

Reference: Model rules validation

Created 16 years ago by krillzip krillzip, updated 12 years ago by Rodrigo Rodrigo.

This is a reference to be used for Model rule validation and is compiled from the Yii documentation and code. The purpose is to have all the information gathered in one place instead of scattered. This reference is not an intro. See The Definitive Guide to Yii, Declaring Validation Rules for a tutorial.

99 0
114 followers
Viewed: 909 780 times
Version: 1.1
Category: How-tos

Take more control of CGridview and model searching (related model or another controller)

Created 12 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by CeBe CeBe.

Suppose you have an Application in Yii that manages hotels each one has many customers.

2 0
6 followers
Viewed: 45 822 times
Version: 1.1
Category: How-tos

ClientValidation for files (modern browsers)

Created 12 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by CeBe CeBe.

There are cases that you want to validate the file format, size, extension etc but how to do that without submit the form ?

2 0
6 followers
Viewed: 20 848 times
Version: 1.1
Category: How-tos

Update CGridview row separately using ajax request

Created 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

There are cases you want to update a record on CGridview directly

5 0
8 followers
Viewed: 27 379 times
Version: 1.1
Category: How-tos

How to store array/widget configuration to the database with config validation rules

Created 11 years ago by Kartik V Kartik V, updated 11 years ago by Kartik V Kartik V.

Note the tag {{homeUrl}} will be dynamically replaced at runtime.

2 3
41 followers
Viewed: 28 087 times
Version: 2.0
Category: Tutorials

Generate a multi-lever array sub-category for a menu

Created 12 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

Everyone have seen a multilayer menu in several CMS

7 0
8 followers
Viewed: 30 778 times
Version: 1.1
Category: How-tos

Generate CTreeview from database table and update a model

Created 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

Suppose we want to set a category to product (or an item in general term), Also suppose categories has sub-categories (multi-level)

1 0
1 follower
Viewed: 15 388 times
Version: 1.1
Category: How-tos

Insert a model record using CGridview

Created 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

CGridview displays existent rows of the table (using DataProvider)

2 0
1 follower
Viewed: 19 802 times
Version: 1.1
Category: How-tos

Save or Update Multiple related model values in one Tabular input form

Created 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

In this wiki I will show you how to save/update a model with many related model For example: How to set a product to multiple categories only in one post form ?

1 0
1 follower
Viewed: 42 480 times
Version: 1.1
Category: Tutorials

Model validation for field ranges using yii2-field-range extension

Created 11 years ago by Kartik V Kartik V, updated 11 years ago by Kartik V Kartik V.

The yii2-field-range extension enables you to easily setup ActiveField range fields with Bootstrap styling. You basically can setup two attributes joined together like a single field with combined validation error block.

0 0
37 followers
Viewed: 31 666 times
Version: 2.0
Category: Tips

Sort and save order of model-elements drag & drop

Created 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz), updated 11 years ago by Kostas Apazidis (KonApaz) Kostas Apazidis (KonApaz).

Suppose you have Products,Categories and each product belongs in many categories

1 0
4 followers
Viewed: 22 056 times
Version: 1.1
Category: Tutorials

Expert's model generation with Gii

Created 11 years ago by le_top le_top, updated 11 years ago by le_top le_top.

Efficient coding with Yii implies efficient use of the code generator. This article shares the personalised Gii templates that were built starting from the standard templates proposed by AweGen.

1 0
2 followers
Viewed: 19 496 times
Version: 1.1
Category: Tips