MYQL type of source code

Source: Internet
Author: User

<?phpclass opmysql{private $host = ' localhost ';//server address private $name = ' root ';//login Private $pwd = ' root ';//Login Password pri Vate $db = ' db ';//database name private $conn = ';//Database Link resource private $result = ';//result set private $msg = ';//return result private $fields; Returns the number of fields private $fieldsNum = 0;//Returns the number of results of the field $rowsNum the number of results of the returned row private $rowsRst = ';//returns an array of individual records private $fiel Dsarray = Array ();//returns the field array private $rowsArray = Array ();//returns multiple result arrays//initializes class function __construct ($host = ', $name = ', $pwd = ' ', $db = ') {if ($host = = ') {$this->host = $host;} if ($name = = ") {$this->name = $name;} if ($pwd = = ") {$this->pwd = $pwd;} if ($db = = ") {$this->db = $db;} $this->init_conn ();} Link database function Init_conn () {$this->conn = @mysql_connect ($this->host, $this->name, $this->pwd); @mysql_ select_db ($this->db, $this->conn); mysql_query ("Set names gb2312");} Query result set function Mysql_query_rst ($sql) {if ($this->conn== ") {$this->init_conn ();} $this->result = @mysql_query ($sql, $this->conn);} Get Field number Function Getfieldsnum ($sql) {$this->mysql_query_rst ($sql); $this->fieldsnum = @mysql_num_fields ($this->result) ;} Gets the total number of rows function Getrowsnum ($sql) {$this->mysql_query_rst ($sql); if (mysql_errno () = = 0) {return @mysql_num_rows ($ THIS-&GT;RESULT,MYSQL_ASSOC);} Else{return ';}} Gets the number of single records function Getrowsrst ($sql) {$this->mysql_query_rst ($sql); if (mysql_errno () = = 0) {$this->rowsrst =mysql _fetch_array ($this-&GT;RESULT,MYSQL_ASSOC); return $this->rowsrst;} Else{return ';}} Gets multiple records function Getrowsarray ($sql) {$this->mysql_query_rst ($sql), if (mysql_errno () = = 0) {while ($row = Mysql_fetch _array ($this->result,mysql_assoc) {$this->rowsarray[] = $row;} return $this->rowsarray;} Else{return ';}} Update, delete, insert record function Uidrst ($sql) {if ($this->conn = =) {$this->init_conn ();} @mysql_query ($sql); $this->rowsnum = Mysql_affected_rows (); if (mysql_errno () = = 0) {return $this->rowsnum;} Else{return ';}} Gets the number of fields corresponding to function GetFields ($sql, $fields) {$this->mysql_query_rst ($sql); if (Mysql_errno () == 0) {if (Mysql_num_fields ($this->result) > 0) {$tmp = @mysql_fetch_row ($this->result); $this->fieldsarray = $tmp [$fields]}return $this->fieldsarray;} Else{return ';}} Error message function Msg_error () {if (Mysql_errno ()! = 0) {$this->msg = Mysql_error ();} return $this->msg;} Release result set function Close_rst () {mysql_free_result ($this->result), $this->msg = "; $this->fieldsnum =0; $this- >rowsnum =0; $this->fieldsarray = "; $this->rowsarray =";} Close Database function Close_conn () {$this->close_rst (); Mysql_close ($this->conn); $this->conn = ';} $conne = new Opmysql ();}? >

MYQL type of source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.