public function test___destruct()
 {
     $statement = $this->cache->get(0);
     unset($this->cache);
     $this->expectException(Exception::class);
     $statement->sqlstate;
 }
Beispiel #2
0
 /**
  * @param $sql
  *
  * @return \mysqli_stmt
  * @throws \Exception
  */
 public function get_statement_from_sql($sql) : \mysqli_stmt
 {
     $key = md5($sql);
     if (!$this->statementCache->exists($key)) {
         // prepare the statement
         $statement = $this->mysqli->prepare($sql);
         if ($statement === false) {
             throw new \Exception("statment preparation failed: ({$this->mysqli->errno}) {$this->mysqli->error}" . PHP_EOL . $sql);
         }
         $this->statementCache->put($key, $statement);
     }
     return $this->statementCache->get($key);
 }