php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63798 Add dbname to mysqli_prop
Submitted: 2012-12-18 21:07 UTC Modified: 2017-04-06 10:03 UTC
From: thbley at gmail dot com Assigned:
Status: Wont fix Package: MySQLi related
PHP Version: 5.5.0alpha1 OS: win7 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thbley at gmail dot com
New email:
PHP Version: OS:

 

 [2012-12-18 21:07 UTC] thbley at gmail dot com
Description:
------------
The properties of the Mysqli object already contain server-info, server-version, errors, etc., but not the current (selected) database.
It would be great if dbname could be added to mysqli properties.
With the property it gets easier to check if the right database was selected or if none was selected.

Test script:
---------------
PHP code looks like this:

class mysqli_db extends mysqli {
  public function __construct($host=null, $user=null, $pw=null, $db=null) {
    call_user_func_array("parent::__construct", func_get_args());
    $this->db = $db;
  }
  // same for real_connect() ...

  public function select_db($db) {
    parent::select_db($db);
    $this->db = $db;
  }
}

$db = new mysqli_db('127.0.0.1', 'root', '', 'test');
echo $db->db; // test

$db->select_db('test2');
echo $db->db; // test2


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-06 10:03 UTC] johannes@php.net
-Status: Open +Status: Wont fix
 [2017-04-06 10:03 UTC] johannes@php.net
We can't do this as we don't necessarily have the information. If a script for instance does query("USE other_db") mysqli won't notice.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC