Laravel additions and deletions to the database set routing settings

Source: Internet
Author: User
Tags php foreach

Laravel Framework's routing settings:          URL:   http://www.shanzezhao.com/laraverl/my_laravel/public/index.php/indexs


Laravel database settings for the framework: config/database.php
1  ' mysql ' = [
2 ' driver ' = ' mysql ', 3 ' host ' = ' localhost ', 4 ' port ' = ' 3306 ', 5 ' database ' = ' laravel ' , 6 ' username ' + ' root ', 7 ' password ' = ' 123456 ', 8 ' unix_socket ' = ', ' 9 ' charset ' = > ' UTF8 ', ' collation ' = ' utf8_unicode_ci ', one ' prefix ' = ', ' strict ' and true,13 ' engine ' = null,14 ],


Laravel frame Additions and deletions::


1 <?php 2 3 4 namespace app\http\controllers; 5 6 use DB; 7 use App\http\controllers\controller; 8 9 class Indexcontroller extends Controller11 {12 13//Add display Public Function index () {retur N View (' Index/index '); 17 18}19//Add Public Function Add () {$name =$_post[' uname '];24 $pwd =$_post[' upwd '];25//Print_r ($PWD);d ie;26//Set Data sheet
      $re =db::table (' Text1 ')->insert ([' uname ' = = $name, ' upwd ' =>md5 ($pwd)]), +//Print_r ($re);d ie;28 if ($re) {redirect (' Show '); 31}32}33//Data display public function show () {$re = db::table (' Text1 ')->get (), PNS/Print_r ($re);d ie;38 return view (' Index/show ', [ ' Re ' = $re]); 39}40//delete Deletes (), =$_get[' id '];44//Print_r ($id);d ie;45 $re = db::table (' Text1 ')->where (' id ', $id)->delete (); $re) (redirect) (' Show '), 51}52 53}54//Modify page Public function updates ( ) ($id =$_get[' id '];58//print_r ($id);d ie;59 $re = db::table (' Text1 ')->where (' id ', $id)- >first () Print_r ($re);d ie;61 return view (' index/upd ', [' re ' + $re]); 62 63 64}65//Modify 6 6 Public Function Upd () =$_post[{$name ' uname '];69 $pwd =$_post[' upwd '];70 $id =$_post[' id '];71 $arr =array (' id ' = $id, ' uname ' = $name, ' upwd ' + $pwd); $re =db::table (' Text1 ')->where (' id ', ' = ', $id) ->update ($arr); ($re) (redirect) (' Show '); 78}79 80 81 }82 83}

The form and the previously learned framework are roughly the same.

resources/views/index/index.blade.php

<! DOCTYPE html>

show.php

<! DOCTYPE html>

upd.php

 <! DOCTYPE html>

Laravel additions and deletions to the database set routing settings

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.