Home  >  Article  >  PHP Framework  >  Yii implements querying a piece of data based on id

Yii implements querying a piece of data based on id

王林
王林Original
2020-02-17 16:48:493221browse

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[&#39;ag_id&#39;] ?>

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn