Home > Backend Development > PHP Tutorial > php+mysql,面向对象,查询

php+mysql,面向对象,查询

WBOY
Release: 2016-06-02 11:33:58
Original
1175 people have browsed it

php

class mysql{
public $host;
public $root;
public $password;
public $database;

<code>    function __construct ($host,$root,$password){        $this->host     =$host;                                         $this->root     =$root;        $this->password =$password ;    }    function connect (){        @mysql_connect  ($this->host,$this->root,$this->password);        mysql_select_db ($this->database);        mysql_query     ("set names utf8");    }    function close(){        mysql_close();    }    function select(){        $result=mysql_query("select * from users");        print_r ($result);    }}    $link=new mysql("localhost","root","","stu_system");$link->connect();$link->select();$link->close();</code>
Copy after login

?>
入手几天,用面向对象的,写到最后感觉我还是在面向过程写,怎么回事~~~
最后是网页不显示信息。
本人自学,能力有限~~求教呀~~

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template