$customer->name = 'kiwi'; $customer->save(); $customer = Fruits::findOne(1); //will update $customer->name = 'kiwi'; $customer->save(); $fruitObject = Fruits::findOne(1); $fruitObject->updateCounters(['somedata1' => 1]); //SET somedata1 = samedata1 + 1 */ $fruit = Fruits::findOne(['name' => 'pineapple']); Fruits::getDb()->transaction(function ($db) use($fruit) { $fruit->somedata1 = 3; $fruit->save(); }); $fruitObject = Fruits::findOne(1); echo '<pre>'; print_r($fruitObject); echo '</pre>'; echo "<br>"; print_r($fruitObject->name); echo "<br>"; $fruitObject = Fruits::findAll(['color' => 'brown']); /* echo '<pre>'; print_r($fruitObject); echo '</pre>'; echo "<br>"; */ ?> <h4>fruits/second</h4> <p>
/** * Finds the Fruits model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Fruits the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Fruits::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }