zoukankan      html  css  js  c++  java
  • MySQL0001:数据库CMD常用操作, 数据添加 查询操作

    1,

    // 数据库操作
    /*
        mysql -hlocalhost -uroot -p
        set names gbk;
        show databases;
        CREATE DATABASE IF NOT EXISTS `oupai` CHARSET utf8;
        USE oupai;
        show tables;
    
         CREATE TABLE IF NOT EXISTS `phoneNumber`(
        `id` int not null auto_increment primary key, #ID
        `phone` int not null, #号码
        `pwd` varchar(32) #密码
        )ENGINE=InnoDB;
    
        INSERT INTO `phonenumber`(phone,pwd) VALUES(18002551987,'f8fe8f06a65f05e23be0b602f7aa7a16');
    
        CREATE TABLE IF NOT EXISTS `phonenum`(
        `id` int not null auto_increment primary key, #ID
        `phone` char(11) not null, #号码
        `pwd` varchar(32) #密码
        )ENGINE=InnoDB;
    
        INSERT INTO `phonenum`(phone,pwd) VALUES('18002551987','f8fe8f06a65f05e23be0b602f7aa7a16');
    
        DROP TABLE phonenum;
    
    */
    
    
    // echo md5("603833");
    
    
    
    
    
    
    
    // //获取地址栏传递的id
    // $id = $_GET['id'];
    
    // //判断用户名和密码与数据库是否一致
    // $sql = "SELECT * FROM user WHERE username='$username' and password='$password'";
    
    
    
    //构建查询的SQL语句
    // $sql = "SELECT * FROM phonenum";
    // //执行SQL语句,并返回结果集对象
    // $result = mysqli_query($link, $sql);
    
    
    
    // //从结果集获取一条记录
    // $arr = mysqli_fetch_array($result,MYSQL_ASSOC);
    
    
    
    //取回记录数:0没找到,1找到了
    // $records = mysqli_num_rows($result); 
    
    
    
    //获取一行数据
    // $arr = mysqli_fetch_assoc($result);
    // echo $arr['phone'];
    
    // echo $result;
    // print_r($result);
    
    // print_r($records);
    
    
    
    // ===================================================================================================
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    // print_r($arrData);
    
    
    
    //=====================================  給数据库添;加原始数据 ============================================
    
    
    
    //// 从文件中读取数据到PHP变量 
    // $json_string = file_get_contents('opEsun.json'); 
    
    // // 用参数true把JSON字符串强制转成PHP数组 
    // $data = json_decode($json_string, true); 
    // echo count($data);
    // // print_r($data[0]['mobile']);
    
    //   $nnn = 0;
    //  foreach ($data as $key => $value) {
    //    // if($value["type"] == $type){
    //    //  $results = $value;
    //    // }
    //    // echo $value;
    //    // print_r($value['mobile']);
    //    // echo $value['mobile'],  '<br>';
    //    // print_r($value['mobile']);
    
    //    // $nnn ++;
    //    // $mobnum = $value['mobile'];
    //    // $sql = "INSERT INTO `phonenum`(phone,pwd) VALUES('".$mobnum."','f8fe8f06a65f05e23be0b602f7aa7a16')";
    //    // if(mysqli_query($link, $sql))
    //    // {
    //    //     echo "<h2>数据添加成功{$nnn}</h2>";
    //    //     // die();              
    //    // }
    
    
    //    // $nnn ++;
    //    // if($nnn > 1){
    //    //     die();
    //    // }
    
    
    //    // sleep(2);
    //    // sleep(3);//暂停3秒
    //    // echo "123<br>";
    
    //  }
    
    
    //=================================================================================
    
    
    
    
    
    
    
    
    // for($i=1;$i<10; $i++){
    //     sleep(5); //暂停 5秒
    // echo date('h:i:s') . "<br />";
    
    // }
    
    
    
    
    // sleep(5); //暂停 5秒
    // echo date('h:i:s') . "<br />";
    
    
    // 显示出来看看 
    // var_dump($json_string); 
    // var_dump ($data); 
    // print_r($data); 
    //产品循环
    // function foreachFun($d,$type,$proId)
    // {
    //  foreach ($d["goods"] as $key => $value) {
    //    if($value["type"] == $type){
    //     $results = $value;
    //    }
    //  }
    //  foreach ($results["product"] as $key => $value) {
    //    if($value["id"] == $proId){
    //     $result = $value;
    //    }
    //  }
    //  return $result;
    // }
    // $res = foreachFun($data,$type,$proId);
    // print_r($res);
    
    
    
    
    
    
    
    
    
    
    
    
    
    //(2)判断记录是否添加成功
    
    // $sql = "INSERT INTO `phonenum`(phone,pwd) VALUES('15557517847','f8fe8f06a65f05e23be0b602f7aa7a16')";
    
    // if(mysqli_query($link, $sql))
    // {
    //     echo "<h2>数据添加成功</h2>";
    //     // header("refresh:3;url=./index.php");
    //     die();              
    // }
    
    
    
    
    
    
    //    // $sql = "INSERT INTO `phonenum`(phone,pwd) VALUES('".$mobnum."','f8fe8f06a65f05e23be0b602f7aa7a16')";
    //    // if(mysqli_query($link, $sql))
    //    // {
    //    //     echo "<h2>数据添加成功{$nnn}</h2>";
    //    //     // die();              
    //    // }
    
    
    // $sql = "select * from mr_user where username = :username";
    // $user = $db->row($sql, array('username' => $to));
    琥珀君的博客
  • 相关阅读:
    代码重构技术方法
    《算法导论》为什么经典
    BeagleBone Black教训四局:简单LED对照实验
    linux(Ubuntu)安装QQ2013
    ubuntu卸载qq2012
    android弧形进度条,有详细注释的,比较简单
    Android自定义进度条
    AndroidのUI设计研究(一)——自定义ProgressBar
    介绍几个工作开发中封装的好用的android自定义控件
    android自定义viewgroup之我也玩瀑布流
  • 原文地址:https://www.cnblogs.com/eliteboy/p/13619107.html
Copyright © 2011-2022 走看看