Benutzer-Werkzeuge

Webseiten-Werkzeuge


select

**Dies ist eine alte Version des Dokuments!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== DB: Abfragen ====== <code php> // return a single customer whose ID is 123 // SELECT * FROM `customer` WHERE `id` = 123 $customer = Customer::find() ->where(['id' => 123]) ->one(); // return all active customers and order them by their IDs // SELECT * FROM `customer` WHERE `status` = 1 ORDER BY `id` $customers = Customer::find() ->where(['status' => Customer::STATUS_ACTIVE]) ->orderBy('id') ->all(); // return the number of active customers // SELECT COUNT(*) FROM `customer` WHERE `status` = 1 $count = Customer::find() ->where(['status' => Customer::STATUS_ACTIVE]) ->count(); // return all active customers in an array indexed by customer IDs // SELECT * FROM `customer` $customers = Customer::find() ->indexBy('id') ->all(); </code> ====== Select für Dropdown ====== <code php> $items = ArrayHelper::map(Datatables::find()->select(['datatable_id', 'datatable_name'])->asArray()->all(), 'datatable_id', 'datatable_name'); echo $form->field($model, 'datatable_id')->dropdownList($items, ['prompt'=>'...'] ); </code> ===== Eager Loading ===== <code php> $player = PlayersModel::find()->where(['id' => $id])->with('club')->one(); $class = Classes::find()->where(['id' => $class_id])->with('dancesClasses', 'dancesClasses.dances')->one(); </code>

select.1566126058.txt.gz · Zuletzt geändert: 2019/08/18 13:00 von jonas