zoukankan      html  css  js  c++  java
  • php :: mysql

     

    mysql_php 大全

    <?php
        $con = mysql_connect("localhost", "root", "dami");
        if(!$con)
        {
            die('不能连接到指定数据库');
        }
        mysql_select_db("lesson", $con);
        //mysql_query("insert into student values(226,'书籍',26,'this is description')");
        //mysql_query("update student set des = 'the des of joan' where id = 2");
        //mysql_query("delete from student where id = 226");
        $result = array();
        $result_temp = mysql_query("select * from student");
        while($row = mysql_fetch_array($result_temp))
            $result[] = $row;
        //print_r($result);
        foreach($result as $index => $student)
        {
            echo "$index 
    ";
            print_r($student);
            echo "
    ";
        }
        //var_dump($result);
        mysql_close($con);
    ?>

    $con = mysql_connect("localhost", "root", "abc123");    //建立数据库连接

    mysql_select_db("db_name", $con);                                       //选择数据库

    mysql_query("select * from student", $con);        // 数据库查询

    mysql_query("insert into student(id,name) values(2,'student_one_name')");   //插入数据

    //mysql_query获取的数据处理

    while($row = mysql_fetch_array($result))

      $result[] = $row;

    mysql_close($con);                  //数据库连接关闭

    修改列属性默认值: alter table t_sap_account_history alter column check_status set default 0

  • 相关阅读:
    7. 流程控制
    6. 工作区域与包
    5. Go函数
    4. Go常量
    面试题1
    数据库三范式
    触发器和存储过程
    面试题
    js 程序执行与顺序实现详解 ,来自网上
    基础的优化数据库查询,个人笔记
  • 原文地址:https://www.cnblogs.com/maxiaoshuai/p/6824924.html
Copyright © 2011-2022 走看看