zoukankan      html  css  js  c++  java
  • 面向对象2

    <?php
    class mysql{
    private $link;
    private $user ="root";
    private $pwd ="";
    private $db ="test";
    private $charst ="utf8";
    private $coon ="";

    public function __construct($link = "localhost" ,$user= "root",$pwd="lovo",$db="test",$charst="utf8"){
    $this->link=$link;
    $this->user=$user;
    $this->pwd=$pwd;
    $this->bd=$db;
    $this->charst=$charst;
    $this->coon=get_con();


    }
    public function get_con(){
    // $this->coon = mysql_connect($this->link,$this->user,$this->pwd) or die(mysql_error());
    $coon = mysql_connect($this->link,$this->user,$this->pwd) or die(mysql_error());
    mysql_select_db($this->db,$this->coon);
    mysql_query("set names '$this->charst'");

    return $coon;
    }


    public function myquery1($sql){
    $result = mysql_query($sql);
    return $result;
    }

    public function delete($sql){

    $this->myquery1($sql);
    return mysql_affected_rows(); //如果执行删除成功,那么肯定有受影响的行数
    // return $result;
    }
    public function insert($sql){

    $this->myquery1($sql);
    return mysql_affected_rows();
    // return $result;
    }

    }

    $mysql = new mysql("localhost","root","","test","utf8");
    ?>

  • 相关阅读:
    eclipse中的项目如何打成war包
    【SVN】Please execute the 'Cleanup' command.
    2021.06.02模拟赛DP2
    2021.05.26模拟赛 DP1
    状压DP
    高斯消元
    矩阵快速幂
    2021.05.10讲题
    Luogu P2152[SDOI 2009]Super GCD
    Tarjan
  • 原文地址:https://www.cnblogs.com/cd-snoopy/p/3746528.html
Copyright © 2011-2022 走看看