query..? 我是个初学者"/> query..? 我是个初学者">

关于$this->query

WBOY
Release: 2016-06-06 20:39:26
Original
1582 people have browsed it

大家好,我有个问题。。

我刚理解 PHP的Class

也会简单应用一下 $this->host();

我就是想问下 怎么把 mysql_query("select * xxxxxx");
把这个 mysql_query 做成 $this->query..?

我是个初学者

回复内容:

大家好,我有个问题。。

我刚理解 PHP的Class

也会简单应用一下 $this->host();

我就是想问下 怎么把 mysql_query("select * xxxxxx");
把这个 mysql_query 做成 $this->query..?

我是个初学者

首先你要定义一个类

<code>php</code><code>class a{
    function query($sql)
    {
        return mysql_query($sql);
    }
    function fetch_array($sql)
    {
        // $this-query();这样弄,
        return mysql_fetch_array($this->query($sql));
    }
    // ...
    function insert($sql)
    {
        $this->query($sql);
        return mysql_insert_id();
    }

}
</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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!