**Dies ist eine alte Version des Dokuments!** ----
====== 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>