Exemplos de uso de Active record instance em Inglês e suas traduções para o Português
{-}
-
Colloquial
-
Official
-
Medicine
-
Financial
-
Ecclesiastic
-
Ecclesiastic
-
Computer
-
Official/political
Note: You cannot link two newly created Active Record instances.
Like normal models, Active Record instances also enjoy the massive assignment feature.
Call a query method to retrieve data in terms of Active Record instances.
When creating a new Active Record instance via the new operator, the following life cycle will happen.
The opposite operation to link() is unlink()which breaks an existing relationship between two Active Record instances.
Dirty Attributes¶ When you call save()to save an Active Record instance, only dirty attributes are being saved.
Info: The link() method will NOT perform any data validation while saving the affected Active Record instance.
You can differentiate the two states of an Active Record instance by checking its isNewRecord property value.
Orders which gives back the customer's order information in terms of an array of Order Active Record instances.
When you return data in Active Record instances, column values will be automatically typecast according to the actual column types;
You can access the column values by accessing the attributes of the Active Record instances, for example.
Selecting extra fields¶ When Active Record instance is populated from query results, its attributes are filled up by corresponding column values from received data set.
Note that data validation will be performed regardless if the Active Record instance has dirty attributes or not.
If a relation is declared with hasMany(), accessing this relation property will return an array of the related Active Record instances;
Using this feature,you can assign values to multiple attributes of an Active Record instance in a single PHP statement, like shown below.
However, it may suffer from a performance issue when you need to access the same relation property of multiple Active Record instances.
The methods described above all work on individual Active Record instances, causing inserting or updating of individual table rows.
Elements in the big array can be either associative arrays(e.g. query results of DAO) orobjects e.g. Active Record instances.
Accessing Data¶ As aforementioned, the data brought back from the database are populated into Active Record instances, andeach row of the query result corresponds to a single Active Record instance.
If a relation is declared with hasOne(), accessing the relation property will return the related Active Record instance or null if no related data is found.
An Active Record class is associated with a database table, an Active Record instance corresponds to a row of that table, and an attribute of an Active Record instance represents the value of a particular column in that row.
Order-> link('customer',$customer); The link()method requires you to specify the relation name and the target Active Record instance that the relationship should be established with.
Sometimes, you may want to pre-populate your Web form for an Active Record instance with these default values.
The method will modify the values of the attributes that link two Active Record instances and save them to the database.
In Accessing Relational Data,we explained that you can access a relation property of an Active Record instance like accessing a normal object property.