rfc:improve_mysqli

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:improve_mysqli [2020/12/30 18:01] – Removed invalid quote dharmanrfc:improve_mysqli [2020/12/30 18:27] (current) – Grammar dharman
Line 43: Line 43:
 === mysqli::init() is confusing, unnecessary, and not an alias of mysqli_init() === === mysqli::init() is confusing, unnecessary, and not an alias of mysqli_init() ===
  
-Despite what the documentation says, ''mysqli::init()'' is not an OOP version of ''mysqli_init()''. In fact, such a claim makes absolutely no sense, given that ''mysqli_init()'' was meant to create an empty instance of mysqli without calling the connect method. In reality, ''mysqli::init()'' is just a thin wrapper for ''%%mysqli::__construct()%%'' with 0 arguments. Gicen the nonsensical nature of this method I am proposing to [[https://github.com/php/php-src/pull/6409|deprecate it in PHP 8.1]]. +Despite what the documentation says, ''mysqli::init()'' is not an OOP version of ''mysqli_init()''. In fact, such a claim makes absolutely no sense, given that ''mysqli_init()'' was meant to create an empty instance of mysqli without calling the connect method. In reality, ''mysqli::init()'' is just a thin wrapper for ''%%mysqli::__construct()%%'' with 0 arguments. Given the nonsensical nature of this method I am proposing to [[https://github.com/php/php-src/pull/6409|deprecate it in PHP 8.1]]. 
  
 The only valid use case for this method was in polymorphism, which can be replaced with a constructor. The only valid use case for this method was in polymorphism, which can be replaced with a constructor.
Line 63: Line 63:
 === "new mysqli()" doesn't open a connection with 0 arguments === === "new mysqli()" doesn't open a connection with 0 arguments ===
  
-At the moment PHP manual claims that all 6 parameters of ''%%mysqli::__construct()%%'' are optional with default values taken from INI settings. As you might have guessed that is not entirely true. The default values are in fact honoured, but at least 1 argument must be provided, even if that 1 argument is ''NULL''. If absolutely no arguments are passed, then ''%%mysqli::__construct()%%'' behaves as ''mysqli_init()''What are the workarounds if want to store all my configuration details in INI?+At the moment PHP manual claims that all 6 parameters of ''%%mysqli::__construct()%%'' are optional with default values taken from INI settings. As you might have guessed that is not entirely true. The default values are in fact honoured, but at least 1 argument must be provided, even if that 1 argument is ''NULL''. If absolutely no arguments are passed, then ''%%mysqli::__construct()%%'' behaves as ''mysqli_init()''Here are the workarounds if you want to store all the configuration details in INI:
  
 <code php> <code php>
Line 248: Line 248:
 The existing prepared statement parameter binding will remain unaffected. There will be no change to ''mysqli_stmt::bind_param()'' The existing prepared statement parameter binding will remain unaffected. There will be no change to ''mysqli_stmt::bind_param()''
  
-The existing procedural style connection will remain the same. The only potential difference would be that `mysqli_connect()with 0 arguments no longer opens the default connection. +The existing procedural style connection will remain the same. The only potential difference would be that ''mysqli_connect()'' with 0 arguments no longer opens the default connection. 
  
-Opening the connection while setting options before will remain the same in procedural form. Setting the connection flags will also remain the same with the only difference that it will now become available using the normal `connect()method too.+Opening the connection while setting options before will remain the same in procedural form. Setting the connection flags will also remain the same with the only difference that it will now become available using the normal ''connect()'' method too.
  
 ===== Future Scope ===== ===== Future Scope =====
rfc/improve_mysqli.1609351273.txt.gz · Last modified: 2020/12/30 18:01 by dharman