<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 數據庫行為 模型行為用于實現通用功能。 與[特性](https://octobercms.com/docs/database/traits)不同,這些[特性](https://octobercms.com/docs/database/traits)可以直接在類中實現,也可以通過擴展類來實現。您可以[在此處](https://octobercms.com/docs/services/behaviors)閱讀有關行為的更多信息。 ### [](https://octobercms.com/docs/database/behaviors#purgeable)可凈化的 創建或更新模型時,清除的屬性不會保存到數據庫中。要清除模型中的屬性,請實現該`October.Rain.Database.Behaviors.Purgeable`行為并`$purgeable`使用包含要清除的屬性的數組聲明一個屬性。 ~~~ class User extends Model { public $implement = [ 'October.Rain.Database.Behaviors.Purgeable' ]; /** * @var array List of attributes to purge. */ public $purgeable = []; } ~~~ 您還可以在類中動態實現此行為。 ~~~ /** * Extend the RainLab.User user model to implement the purgeable behavior. */ RainLab\User\Models\User::extend(function($model) { // Implement the purgeable behavior dynamically $model->implement[] = 'October.Rain.Database.Behaviors.Purgeable'; // Declare the purgeable property dynamically for the purgeable behavior to use $model->addDynamicProperty('purgeable', []); }); ~~~ 保存模型時,在觸發[模型事件](https://octobercms.com/docs/database/behaviors#model-events)(包括驗證)之前,將清除定義的屬性。使用`getOriginalPurgeValue`來查找已清除的值。 ~~~ return $user->getOriginalPurgeValue($propertyName); ~~~ ### [](https://octobercms.com/docs/database/behaviors#sortable)可排序 排序的模型將存儲一個數字值,`sort_order`該值保持集合中每個單獨模型的排序順序。要存儲模型的排序順序,請實現該`October\Rain\Database\Behaviors\Sortable`行為并確保您的模式已定義供其使用的列(例如:)`$table->integer('sort_order')->default(0);`。 ~~~ class User extends Model { public $implement = [ 'October.Rain.Database.Behaviors.Sortable' ]; } ~~~ 您還可以在類中動態實現此行為。 ~~~ /** * Extend the RainLab.User user model to implement the sortable behavior. */ RainLab\User\Models\User::extend(function($model) { // Implement the sortable behavior dynamically $model->implement[] = 'October.Rain.Database.Behaviors.Sortable'; }); ~~~ 您可以通過定義`SORT_ORDER`常量來修改用于標識排序順序的鍵名: ~~~ const SORT_ORDER = 'my_sort_order_column'; ~~~ 使用此`setSortableOrder`方法可以在單個記錄或多個記錄上設置訂單。 ~~~ // Sets the order of the user to 1... $user->setSortableOrder($user->id, 1); // Sets the order of records 1, 2, 3 to 3, 2, 1 respectively... $user->setSortableOrder([1, 2, 3], [3, 2, 1]); ~~~ > **注意:**如果在以前已經存在數據(行)的模型中實現此行為,則可能需要先初始化數據集,然后此行為才能正常工作。為此,請手動更新每一行的`sort_order`列,或者對數據運行查詢以將記錄的`id`列復制到該`sort_order`列(例如`UPDATE myvendor_myplugin_mymodelrecords SET sort_order = id`)。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看