Home > Article > PHP Framework > Yii implements querying a piece of data based on id
Yii implements the method of querying a piece of data based on id as follows:
1. Model layer
public function selectone($ag_id=''){ return $this->findBySql("SELECT * FROM agency where ag_id=$ag_id")->asArray()->one(); }
(Recommended tutorial: yii framework)
2. Controller layer
$ag_id = $_GET['ag_id']; $data = $model -> selectone($ag_id);
3. View layer
./index.php?r=about/agency&ag_id=<?php echo $value['ag_id'] ?>
If you want to know more about programming, please visit php Chinese website Programming TutorialColumn!
The above is the detailed content of Yii implements querying a piece of data based on id. For more information, please follow other related articles on the PHP Chinese website!