扩展MySQLi [英] Extending MySQLi

查看:81
本文介绍了扩展MySQLi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在扩展MySQLi类时遇到了问题.它不会让我添加任何属性.

I've run into problems extending the MySQLi class. It won't let me add any properties.

class MySQLii extends MySQLi {

 public $database;

 public function MySQLii($host, $username, $password, $database){

  // Initialize MySQLi
  parent::MySQLi($host, $username, $password, $database);

  // Save database name
  $this->database = $database;

 }

}

$mysqlii = new MySQLii('localhost', 'root', 'password', 'database');

var_dump($mysqlii);

object(MySQLii)#1(17){
["affected_rows"] => int(0)
["client_info"] =>字符串(48) "mysqlnd 5.0.5-dev-081106- $修订:289630 $"
["client_version"] => int(50005)
["connect_errno"] => int(0)
["connect_error"] => NULL
["errno"] => int(0)["error"] =>
string(0)" ["field_count"] =>
int(0)["host_info"] =>字符串(42) "MySQL主机信息:通过UNIX的Localhost 套接字"[" info] => NULL
["insert_id"] => int(0)
["server_info"] =>字符串(6)"5.1.44" ["server_version"] => int(50144)
["sqlstate"] =>字符串(5)"00000"
["protocol_version"] => int(10)
["thread_id"] => int(4019)
["warning_count"] => int(0)}

object(MySQLii)#1 (17) {
["affected_rows"]=> int(0)
["client_info"]=> string(48) "mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $"
["client_version"]=> int(50005)
["connect_errno"]=> int(0)
["connect_error"]=> NULL
["errno"]=> int(0) ["error"]=>
string(0) "" ["field_count"]=>
int(0) ["host_info"]=> string(42) "MySQL host info: Localhost via UNIX socket" ["info"]=> NULL
["insert_id"]=> int(0)
["server_info"]=> string(6) "5.1.44" ["server_version"]=> int(50144)
["sqlstate"]=> string(5) "00000"
["protocol_version"]=> int(10)
["thread_id"]=> int(4019)
["warning_count"]=> int(0) }

请注意,我没有在MySQLii构造函数中添加的database属性.我想念什么吗?

Note the absence of the database property I added in the MySQLii constructor. Am I missing something?

推荐答案

显然,扩展MySQLi类使其无法添加其他属性.错误的PHP.不好.

Apparently extending the MySQLi class makes it impossible to add additional properties. Bad PHP. Bad.

这篇关于扩展MySQLi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆