关于Yii框架基础的增删查改
来源:互联网 发布:python 遥感贝叶斯 编辑:程序博客网 时间:2024/05/22 06:18
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
class DemoController extends Controller{
public $enableCsrfValidation = false;
public function actionIndex(){
return $this->render("index");
}
public function actionAdd()
{
$name = Yii::$app->request->post('name');
$res=Yii::$app->db->createCommand("insert into diyi(`name`) value('$name')")->execute();
return $this->redirect(['demo/show']);
}
public function actionShow()
{
header("content-type:text/html;charset=utf-8");
$data = Yii::$app->db->createCommand("select * from `diyi`")->queryAll();
return $this ->render('show',['data'=>$data]);
}
public function actionDel()
{
$id = Yii::$app->request->get('id');
$del = Yii::$app->db->createCommand("delete from diyi where id = '$id'")->execute();
return $this->redirect(['demo/show']);
}
public function actionFind()
{
$id = Yii::$app->request->get('id');
$data = Yii::$app->db->createCommand("select * from diyi where id = '$id'")->queryAll();
$res=$data[0];
return $this->render('find',['res'=>$res]);
}
}
namespace app\controllers;
use Yii;
use yii\web\Controller;
class DemoController extends Controller{
public $enableCsrfValidation = false;
public function actionIndex(){
return $this->render("index");
}
public function actionAdd()
{
$name = Yii::$app->request->post('name');
$res=Yii::$app->db->createCommand("insert into diyi(`name`) value('$name')")->execute();
return $this->redirect(['demo/show']);
}
public function actionShow()
{
header("content-type:text/html;charset=utf-8");
$data = Yii::$app->db->createCommand("select * from `diyi`")->queryAll();
return $this ->render('show',['data'=>$data]);
}
public function actionDel()
{
$id = Yii::$app->request->get('id');
$del = Yii::$app->db->createCommand("delete from diyi where id = '$id'")->execute();
return $this->redirect(['demo/show']);
}
public function actionFind()
{
$id = Yii::$app->request->get('id');
$data = Yii::$app->db->createCommand("select * from diyi where id = '$id'")->queryAll();
$res=$data[0];
return $this->render('find',['res'=>$res]);
}
}
阅读全文
0 0
- 关于Yii框架基础的增删查改
- YII框架数据库的增删改查
- Yii框架的增删改查
- YII框架数据库的增删改查
- YII框架数据库的增删改查
- YII框架的增删改查
- Yii框架下的增删改查
- yii框架的增删改查
- yii框架的增删改查语句
- Yii框架增删改查
- yii 框架增删改查
- Yii 框架增删改查
- yii的增删改查
- yii的增删改查
- yii的增删改查
- 关于后盾网yii框架的学习小结(10)--使用AR类的增删改查
- 关于后盾网yii框架的学习小结(10)--使用AR类的增删改查
- yii框架 AR增删改查 分页
- Android TV 开发总结概览
- Eclipse neon 安装SVN插件
- Haar-like、HoG 、LBP 三种描述方法在目标识别中的优劣
- 利用镜面反射让游戏闪耀起来
- 排序算法之堆排序--Java语言
- 关于Yii框架基础的增删查改
- Codeforces Round #406 (Div. 1) A. Berzerk 记忆化搜索
- [微信小程序]点击切换卡片动画效果
- 使用Python获取网站的图片(2.7和3版本)
- 二、开始Tango API(C语言版)
- 用函数编写计算m!
- spring boot 配置 swagger2
- 打开文档变肉鸡:潜伏17年的“噩梦公式”Office漏洞攻击分析
- Ubuntu系统修复