2

我正在我的一门课程中扩展 mysqli。它工作得很好,但连接增加了大约 1 秒的 php 加载时间。我想知道是否有更快或更合适的方式连接到 MySql,或者是否可以构建数据库增强功能以​​加快执行速度?

1 秒的开销纯粹是我的 WAMP 服务器上的连接,这是在我运行任何其他查询之前。

有任何想法吗?

谢谢

class db extends mysqli {
    //ACCESS VARIABLES FOR ENTIRE SITE
    protected $_host = 'myhost';
    protected $_user = 'myuser';
    protected $_pass = 'mypass';
    protected $_db = 'mydb';

    function __construct() {
       echo microtime(true)."<br />";
           parent::__construct($this->_host, $this->_user, $this->_pass, $this->_db);
       if ($this->connect_errno) die('Connect Error: ' . $this->connect_errno);
       $this->set_charset("utf8");
           echo microtime(true)."<br />";
    }
}
4

1 回答 1

-1

您是否尝试过删除echo语句以查看是否可以提高运行时间?

我将向您推荐 Mysqli 文档页面以了解其他连接方式:http ://www.php.net/manual/en/mysqli.quickstart.connections.php

于 2013-07-24T15:37:34.283 回答