99use ezsql \DatabaseInterface ;
1010
1111class ez_mysqli extends ezsqlModel implements DatabaseInterface
12- {
13- /*
14- * ezSQL error strings - mySQLi
15- * @var array
16- */
17- private $ ezsql_mysql_str = array
18- (
19- 1 => 'Require $name to select a database ' ,
20- 2 => 'mySQL database connection is not active ' ,
21- 3 => 'Unexpected error while trying to select database '
22- );
23-
12+ {
2413 private static $ isSecure = false ;
2514 private static $ secure = null ;
2615
@@ -43,12 +32,12 @@ class ez_mysqli extends ezsqlModel implements DatabaseInterface
4332 private $ database ;
4433
4534 public function __construct (ConfigInterface $ settings = null ) {
46- if ( ! \class_exists ('ezsqlModel ' ) ) {
35+ if ( ! \class_exists ('ezsqlModel ' ) ) {
4736 if ( ! \interface_exists ('Psr\Container\ContainerInterface ' ) )
4837 throw new Exception (\CONFIGURATION_REQUIRES );
4938 }
5039
51- if (empty ($ settings ) || (! $ settings instanceof ConfigInterface) ) {
40+ if (empty ($ settings )) {
5241 throw new Exception (\MISSING_CONFIGURATION );
5342 }
5443
@@ -147,19 +136,15 @@ public function select($name = '', $charset = '')
147136 {
148137 $ this ->_connected = false ;
149138 $ name = empty ($ name ) ? $ this ->database ->getName () : $ name ;
150- if ( ! $ name ) {
151- // Must have a database name
152- $ this ->register_error ($ this ->ezsql_mysql_str [1 ] . ' in ' . __FILE__ . ' on line ' . __LINE__ );
153- $ this ->show_errors ? \trigger_error ($ this ->ezsql_mysql_str [1 ], \E_USER_WARNING ) : null ;
154- } elseif ( ! $ this ->dbh ) {
139+ if ( ! $ this ->dbh ) {
155140 // Must have an active database connection
156- $ this ->register_error ($ this -> ezsql_mysql_str [ 2 ] . ' in ' . __FILE__ . ' on line ' . __LINE__ );
157- $ this ->show_errors ? \trigger_error ($ this -> ezsql_mysql_str [ 2 ] , \E_USER_WARNING ) : null ;
141+ $ this ->register_error (\ FAILED_CONNECTION . ' in ' . __FILE__ . ' on line ' . __LINE__ );
142+ $ this ->show_errors ? \trigger_error (\ FAILED_CONNECTION , \E_USER_WARNING ) : null ;
158143 } elseif ( !\mysqli_select_db ($ this ->dbh , $ name ) ) {
159144 // Try to connect to the database
160145 // Try to get error supplied by mysql if not use our own
161146 if ( !$ str = \mysqli_error ($ this ->dbh )) {
162- $ str = $ this -> ezsql_mysql_str [ 3 ] ;
147+ $ str = ' Unexpected error while trying to select database ' ;
163148 }
164149
165150 $ this ->register_error ($ str . ' in ' .__FILE__ . ' on line ' . __LINE__ );
0 commit comments