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

Yii implements querying a piece of data based on id

王林
Release: 2020-02-17 16:48:49
Original
3260 people have browsed it

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();
    }
Copy after login

(Recommended tutorial: yii framework)

2. Controller layer

$ag_id = $_GET['ag_id'];
$data = $model -> selectone($ag_id);
Copy after login

3. View layer

./index.php?r=about/agency&ag_id=<?php echo $value[&#39;ag_id&#39;] ?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template