码迷,mamicode.com
首页 > 其他好文 > 详细

面向对象2

时间:2014-05-26 13:53:21      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:c   class   a   get   set   cti   

 

 

 

<?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");
?>

面向对象2,布布扣,bubuko.com

面向对象2

标签:c   class   a   get   set   cti   

原文地址:http://www.cnblogs.com/cd-snoopy/p/3746528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!