Exemplo n.º 1
0
 public function test___destruct()
 {
     $statement = $this->cache->get(0);
     unset($this->cache);
     $this->expectException(Exception::class);
     $statement->sqlstate;
 }
Exemplo n.º 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);
 }