Code sharing _javascript tips for selecting, selecting, selecting, removing, deleting, deleting, or changing storage (operating in a yii framework) in JavaScript

Source: Internet
Author: User
Tags yii

Effect Display:

Code implementation:

Controller

<?php namespace App\controllers; 
Use Yii; 
Use Yii\filters\accesscontrol; 
Use Yii\web\controller; 
Use Yii\filters\verbfilter; 
Use App\models\loginform; 
Use App\models\contactform; 
Use Yii\db\activerecord; 
Use yii\data\pagination; 
Use App\models\ecsgoods; 
Class Pagecontroller extends Controller {//public $layout =false; 
Show, paging public function actionlist () {$query = Ecsgoods::find (); 
$pagination = new Pagination ([' Defaultpagesize ' => 5, ' totalcount ' => $query->count (),]); 
$countries = $query->offset ($pagination->offset)->limit ($pagination->limit)->all (); 
return $this->render (' list ', [' Brr ' => $countries, ' pagination ' => $pagination,]); 
///point to change Public function actionupdates () {$request = Yii:: $app->request; 
$id = $request->get (' old_id '); 
$name = $request->get (' Old_val '); 
$connection =yii:: $app->db; $command = $connection->createcommand ("Update ecs_goods set goods_name= ' $name ' where goods_iD= ' $id '); 
$re = $command->execute (); 
if ($re) {echo 1; 
//Single Delete public function Actiondel () {$request = Yii:: $app->request; 
$id = $request->get (' IDs '); 
$connection =yii:: $app->db; 
$command = $connection->createcommand ("Delete from ecs_goods where goods_id= ' $id ')"; 
$re = $command->execute (); 
if ($re) {echo 1; 
else {echo 0; 
}///batch Delete public function Actionalldel () {$request = Yii:: $app->request; 
$id = $request->get (' new_str '); 
$connection =yii:: $app->db; 
$command = $connection->createcommand ("Delete from Ecs_goods where goods_id in ($id)"); 
$re = $command->execute (); 
if ($re) {echo 1; 
else {echo 0; 
}} The view layer [HTML] view plain copy on the code to see that a piece of coding is derived to my Code slice <?php use yii\helpers\html; 
Use Yii\widgets\linkpager; ?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

The above is a small set of JavaScript to introduce all of the selected, all do not select, reverse, no refresh delete, bulk Delete, that is, the point is to change warehousing (operation in the YII framework) of the code to share, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.