44
55use Deimos \Config \ConfigObject ;
66use Deimos \Helper \Exceptions \ExceptionEmpty ;
7+ use Deimos \QueryBuilder \AbstractAdapter ;
78use Deimos \QueryBuilder \Adapter ;
89use Deimos \QueryBuilder \Instruction ;
910use Deimos \QueryBuilder \QueryBuilder ;
@@ -31,7 +32,7 @@ class Database
3132 ];
3233
3334 /**
34- * @var Adapter
35+ * @var AbstractAdapter
3536 */
3637 protected $ adapter ;
3738
@@ -45,6 +46,11 @@ class Database
4546 */
4647 protected $ connection ;
4748
49+ /**
50+ * @var \PDOStatement[]
51+ */
52+ protected $ statements = [];
53+
4854 /**
4955 * Database constructor.
5056 *
@@ -101,10 +107,14 @@ public function raw($sql, array $attributes = [])
101107 */
102108 public function rawQuery ($ sql , array $ attributes = [])
103109 {
104- $ statement = $ this ->connection ()->prepare ($ sql );
105- $ statement ->execute ($ attributes );
110+ if (empty ($ this ->statements [$ sql ]))
111+ {
112+ $ this ->statements [$ sql ] = $ this ->connection ()->prepare ($ sql );
113+ }
114+
115+ $ this ->statements [$ sql ]->execute ($ attributes );
106116
107- return $ statement ;
117+ return $ this -> statements [ $ sql ] ;
108118 }
109119
110120 /**
@@ -200,7 +210,6 @@ protected function connect()
200210 //Connection::ATTR_EMULATE_PREPARES => true,
201211 //Connection::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
202212 //Connection::ATTR_PERSISTENT => false,
203- //Connection::ATTR_ERRMODE => Connection::ERRMODE_EXCEPTION,
204213 //Connection::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'
205214 ];
206215
0 commit comments