/** * model实例 */ public function actionModel() { $example = new Example(); $example->showMessage(); //获取所有记录 $all = Example::all(); foreach ($all as $item) { echo '<p>' . $item->name . '</p>'; } echo '<br></br>'; //获取一条记录 $one = Example::find(1); echo '<p>' . $one->name . '</p>'; echo '<br></br>'; //条件查询 $condition = array('name = ?', 'yang'); $where = Example::find('all', array('conditions' => $condition)); foreach ($where as $item) { echo '<p>' . $item->name . '</p>'; } echo '<br></br>'; }