connection = new \SQLite3($dbinfo->m_database); if(!$this->connection){ throw new \Exception('Could not connect to Database. Check ur Database Settings: '.$error);} } /** * Destruct the Database Connection upon Destruction. */ public function __destruct(){ $this->close();} /** * Close the Database Connection. * * @return bool Returns true or false depending on success */ public function close(){ return $this->connection->close();} /** * Query the Connection using Prepare Statement * * @param string $stmtName Name of the Statement - espec for PostgreSQL important * @param string $stmt SQL string of the Statement * @param array $values Array of Prepare Values * @return Result Returns Database Query Result. */ public function prepare($stmtName, $stmt, $values, $types = null){ $prepStmt = $this->connection->prepare($stmt); if(!$prepStmt){ throw new \SYSTEM\LOG\ERROR('Prepared Statement prepare fail: '. $error);} foreach($values as $key=>$val){ $prepStmt->bindParam($key,$val);} if(!($result = $prepStmt->execute())){ throw new \SYSTEM\LOG\ERROR("Could not execute prepare statement: ". $error);} return new ResultSQLite($result,$prepStmt); } /** * Query the Connection using normal Query Statement * * @param string $query SQL string of the Statement * @return Result Returns Database Query Result. */ public function query($query){ $result = $this->connection->query($query); if(!$result){ throw new \SYSTEM\LOG\ERROR('Could not query Database. Check ur Query Syntax or required Rights: '.$this->connection->lastErrorMsg());} if($result === TRUE){ return TRUE;} return new ResultSQLite($result,null); } /** * Exec Query on Database * * @param string $query SQL string of the Statement * @return Result Returns Database Query Result. */ public function exec($query){ return $this->connection->exec($query);} /** * Commit a Transaction on the Database Connection * * @return bool Returns true or false depending on success. */ public function commit(){ throw new \Exception('Could not start Transaction: not implemented');} /** * Open a Transaction on the Database Connection * * @return bool Returns true or false depending on success. */ public function trans(){ throw new \Exception('Could not start Transaction: not implemented');} }