国产女人18毛片水真多18精品, 一区二区三区中文字-亚洲精品女国产, 欧美熟妇老熟妇88888久久久久, 一级毛片免费观看亚洲欧美国产精品,大波霸美女视频,日韩欧美激情V影院,熟女人伦21p,亚洲精品女国产,国产 乱子伦 在线

php入門之連接mysql數(shù)據(jù)庫

時(shí)間:2025-12-03 08:31:53 php語言

php入門之連接mysql數(shù)據(jù)庫

  php入門之連接mysql數(shù)據(jù)庫的一個(gè)類,學(xué)習(xí)php的朋友可以參考下,希望對(duì)大家有所幫助!

  項(xiàng)目結(jié)構(gòu):

  運(yùn)行效果;

  conn.php

  復(fù)制代碼 代碼如下:

  <?php

  class ConnectionMySQL{

  /pic/p>

  private $host="localhost";

  /pic/p>

  private $name="root";

  /pic/p>

  private $pass="";

  /pic/p>

  private $table="phptest";

  /pic/p>

  private $ut="utf-8";

  /pic/p>

  function __construct(){

  $this->ut=$ut;

  $this->connect();

  }

  /pic/p>

  function connect(){

  $link=mysql_connect($this->host,$this->name,$this->pass) or die ($this->error());

  mysql_select_db($this->table,$link) or die("沒該數(shù)據(jù)庫:".$this->table);

  mysql_query("SET NAMES '$this->ut'");

  }

  function query($sql, $type = '') {

  if(!($query = mysql_query($sql))) $this->show('Say:', $sql);

  return $query;

  }

  function show($message = '', $sql = '') {

  if(!$sql) echo $message;

  else echo $message.'<br>'.$sql;

  }

  function affected_rows() {

  return mysql_affected_rows();

  }

  function result($query, $row) {

  return mysql_result($query, $row);

  }

  function num_rows($query) {

  return @mysql_num_rows($query);

  }

  function num_fields($query) {

  return mysql_num_fields($query);

  }

  function free_result($query) {

  return mysql_free_result($query);

  }

  function insert_id() {

  return mysql_insert_id();

  }

  function fetch_row($query) {

  return mysql_fetch_row($query);

  }

  function version() {

  return mysql_get_server_info();

  }

  function close() {

  return mysql_close();

  }

  /pic/p>

  function fn_insert($table,$name,$value){

  $this->query("insert into $table ($name) value ($value)");

  }

  /pic/p>

  function fn_delete($table,$id,$value){

  $this->query("delete from $table where $id=$value");

  echo "id為". $id." 的記錄被成功刪除!";

  }

  }

  $db = new ConnectionMySQL();

  $db->fn_insert('test','id,name,sex',"'','hongtenzone','M'");

  $db->fn_delete('test', 'id', 1);

  ?>

【php入門之連接mysql數(shù)據(jù)庫】相關(guān)文章:

php連接mysql數(shù)據(jù)庫代碼09-13

php基礎(chǔ)之連接mysql數(shù)據(jù)庫和查詢數(shù)據(jù)02-24

PHP對(duì)數(shù)據(jù)庫MySQL的連接操作12-02

PHP腳本測(cè)試連接MySQL數(shù)據(jù)庫12-07

如何在PHP中連接MySQL數(shù)據(jù)庫07-11

PHP與MYSql連接與查詢11-30

PHP連接局域網(wǎng)MYSQL數(shù)據(jù)庫的技巧11-23

PHP連接MYSQL數(shù)據(jù)庫的3種常用方法03-01

php網(wǎng)站如何連接到遠(yuǎn)程mysql數(shù)據(jù)庫11-28