88use Foolz \SphinxQL \Exception \ConnectionException ;
99use Foolz \SphinxQL \Exception \DatabaseException ;
1010use Foolz \SphinxQL \Exception \SphinxQLException ;
11- use mysqli_sql_exception ;
1211
1312/**
1413 * SphinxQL connection class utilizing the MySQLi extension.
@@ -52,12 +51,6 @@ public function connect()
5251 if (!$ conn ->real_connect ($ data ['host ' ], null , null , null , (int ) $ data ['port ' ], $ data ['socket ' ])) {
5352 throw new ConnectionException ('Connection Error: [ ' .$ conn ->connect_errno .'] ' .$ conn ->connect_error );
5453 }
55- } catch (mysqli_sql_exception $ exception ) {
56- throw new ConnectionException (
57- 'Connection Error: [ ' .$ exception ->getCode ().'] ' .$ exception ->getMessage (),
58- (int ) $ exception ->getCode (),
59- $ exception
60- );
6154 } finally {
6255 restore_error_handler ();
6356 }
@@ -109,12 +102,6 @@ public function query($query)
109102 * ERROR mysqli::prepare(): (08S01/1047): unknown command (code=22) - prepare() not implemented by Sphinx/Manticore
110103 */
111104 $ resource = @$ this ->getConnection ()->query ($ query );
112- } catch (mysqli_sql_exception $ exception ) {
113- throw new DatabaseException (
114- '[ ' .$ exception ->getCode ().'] ' .$ exception ->getMessage ().' [ ' .$ query .'] ' ,
115- (int ) $ exception ->getCode (),
116- $ exception
117- );
118105 } finally {
119106 restore_error_handler ();
120107 }
@@ -140,15 +127,7 @@ public function multiQuery(array $queue)
140127
141128 $ this ->ensureConnection ();
142129
143- try {
144- $ this ->getConnection ()->multi_query (implode ('; ' , $ queue ));
145- } catch (mysqli_sql_exception $ exception ) {
146- throw new DatabaseException (
147- '[ ' .$ exception ->getCode ().'] ' .$ exception ->getMessage ().' [ ' .implode ('; ' , $ queue ).'] ' ,
148- (int ) $ exception ->getCode (),
149- $ exception
150- );
151- }
130+ $ this ->getConnection ()->multi_query (implode ('; ' , $ queue ));
152131
153132 if ($ this ->getConnection ()->error ) {
154133 throw new DatabaseException ('[ ' .$ this ->getConnection ()->errno .'] ' .
@@ -167,13 +146,7 @@ public function escape($value)
167146 {
168147 $ this ->ensureConnection ();
169148
170- try {
171- $ value = $ this ->getConnection ()->real_escape_string ((string ) $ value );
172- } catch (mysqli_sql_exception $ exception ) {
173- throw new DatabaseException ($ exception ->getMessage (), (int ) $ exception ->getCode (), $ exception );
174- }
175-
176- if ($ value === false ) {
149+ if (($ value = $ this ->getConnection ()->real_escape_string ((string ) $ value )) === false ) {
177150 // @codeCoverageIgnoreStart
178151 throw new DatabaseException ($ this ->getConnection ()->error , $ this ->getConnection ()->errno );
179152 // @codeCoverageIgnoreEnd
0 commit comments