ar.md 1.27 KB
Newer Older
Qiang Xue committed
1 2 3
ActiveRecord
============

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
Scenarios
---------

All possible scenario formats supported by ActiveRecord:

```php
public function scenarios()
{
    return array(
        // 1. attributes array
        'scenario1' => array('attribute1', 'attribute2'),

        // 2. insert, update and delete operations won't be wrapped with transaction (default mode)
        'scenario2' => array(
            'attributes' => array('attribute1', 'attribute2'),
            'atomic' => array(), // default value
        ),

        // 3. all three operations (insert, update and delete) will be wrapped with transaction
        'scenario3' => array(
            'attributes' => array('attribute1', 'attribute2'),
            'atomic',
        ),

        // 4. insert and update operations will be wrapped with transaction, delete won't
        'scenario4' => array(
            'attributes' => array('attribute1', 'attribute2'),
            'atomic' => array(self::INSERT, self::UPDATE),
        ),

        // 5. insert and update operations won't be wrapped with transaction, delete will
        'scenario5' => array(
            'attributes' => array('attribute1', 'attribute2'),
            'atomic' => array(self::DELETE),
        ),
    );
}
```

Qiang Xue committed
43 44 45 46 47 48 49 50
Query
-----

### Basic Queries

### Relational Queries

### Scopes